/**
  * Encrypt the cookies on an outgoing response.
  *
  * @param \Psr\Http\Message\ResponseInterface $response
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 protected function encrypt(ResponseInterface $response) : ResponseInterface
 {
     foreach ($response->headers->getCookies() as $cookie) {
         if ($this->isDisabled($cookie->getName())) {
             continue;
         }
         $response->headers->setCookie($this->duplicate($cookie, $this->encrypter->encrypt($cookie->getValue())));
     }
     return $response;
 }
Example #2
0
 /**
  * Write values to handler.
  */
 private function writeToHandler()
 {
     $values = $this->values;
     $values[self::METADATA_NAMESPACE] = ['firstTrace' => $this->firstTrace, 'lastTrace' => $this->lastTrace, 'regenerationTrace' => $this->regenerationTrace, 'requestsCount' => $this->requestsCount, 'fingerprint' => $this->fingerprint];
     $this->handler->write($this->id, $this->encrypter->encrypt(json_encode($values, \JSON_PRESERVE_ZERO_FRACTION)));
 }