cookie = $cookie; $this->crypter = $crypter; } /** * Load a session from storage by a given ID. * * If no session is found for the ID, null will be returned. * * @param string $id * @return array */ public function load($id) { if ($this->cookie->has('session_payload')) { return unserialize($this->crypter->decrypt($this->cookie->get('session_payload'))); } } /** * Save a given session to storage. * * @param array $session * @param array $config * @return void */ public function save($session, $config) { if ( ! headers_sent()) { extract($config); $payload = $this->crypter->encrypt(serialize($session)); $this->cookie->put('session_payload', $payload, $lifetime, $path, $domain); } } /** * Delete a session from storage by a given ID. * * @param string $id * @return void */ public function delete($id) { $this->cookie->forget('session_payload'); } }