/** * Encrypt the cookies on an outgoing response. * * @param \Symfony\Component\HttpFoundation\Response $response * @return \Symfony\Component\HttpFoundation\Response */ protected function encrypt(Response $response) { foreach ($response->headers->getCookies() as $key => $cookie) { if ($cookie->getName() == 'PHPSESSID') { // Leave alone the PHPSESSID. continue; } $encrypted = $this->encrypter->encrypt($cookie->getValue()); $response->headers->setCookie($this->duplicate($cookie, $encrypted)); } return $response; }
/** * Store an item in the cache for a given number of minutes. * * @param string $key * @param mixed $value * @param int $minutes * @return void */ public function put($key, $value, $minutes) { $key = $this->prefix . $key; // All of the cached values in the database are encrypted in case this is used // as a session data store by the consumer. We'll also calculate the expire // time and place that on the table so we will check it on our retrieval. $value = $this->encrypter->encrypt($value); $expiration = $this->getTime() + $minutes * 60; try { $this->table()->insert(compact('key', 'value', 'expiration')); } catch (\Exception $e) { $this->table()->where('key', '=', $key)->update(compact('value', 'expiration')); } }