コード例 #1
0
 /**
  * @param Cookies $reqCookies
  *
  * @return array
  */
 private function decryptCookies(Cookies $reqCookies)
 {
     $resCookies = [];
     foreach ($reqCookies->getAll() as $cookie) {
         $name = $cookie->getName();
         if (in_array($name, $this->unencryptedCookies)) {
             continue;
         }
         $decrypted = $this->encryption->decrypt($cookie->getValue());
         if (is_string($decrypted)) {
             $reqCookies = $reqCookies->with($cookie->withValue(new OpaqueProperty($decrypted)));
         } else {
             $reqCookies = $reqCookies->without($name);
             if ($this->deleteInvalid) {
                 $resCookies[] = SetCookie::createExpired($name);
             }
         }
     }
     return [$reqCookies, $resCookies];
 }
コード例 #2
0
 /**
  * Expire a cookie in the response.
  *
  * Do not worry about duplicated cookies, they will be deduped when the
  * response is rendered by "EncryptedCookieMiddleware".
  *
  * @param ResponseInterface $response
  * @param string $name
  *
  * @return ResponseInterface
  */
 public function expireCookie(ResponseInterface $response, $name)
 {
     $cookie = SetCookie::createExpired($name)->withMaxAge($this->configuration['maxAge'])->withPath($this->configuration['path'])->withDomain($this->configuration['domain'])->withSecure($this->configuration['secure'])->withHttpOnly($this->configuration['httpOnly']);
     return $response->withAddedHeader(static::RESPONSE_COOKIE_NAME, $cookie);
 }
コード例 #3
0
 /**
  * @param ResponseInterface $response
  * @param string $cookieName
  *
  * @return ResponseInterface
  */
 public static function expire(ResponseInterface $response, $cookieName)
 {
     return static::set($response, SetCookie::createExpired($cookieName));
 }