cookie = $app->get_cookie(); $this->request = $app->get_request(); $this->user = $user; } /** * @param Trusted_Device $device * * @return bool */ public function set( Trusted_Device $device ) { return $this->cookie->set_cookie( $device->get_device_id(), $device->get_device_key(), self::COOKIE_LIFESPAN, true ); } public function delete_all_set() { foreach ( array_keys( $this->user->get_user_trusted_devices() ) as $device_id ) { $this->delete_if_set( $device_id ); } } /** * @param string $device_id */ public function delete_if_set( $device_id ) { if ( $this->request->get_from_cookie( $device_id ) ) { $this->delete( $device_id ); } } /** * @param string $device_id * * @return bool */ private function delete( $device_id ) { return $this->cookie->delete_cookie( $device_id ); } }