/** * {@inheritdoc} */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response) { $cookieName = 'encrypted-cookie-test'; $cookie = $this->cookie->getCookie($request, $cookieName) ?: 'Not Found (Are encrypted cookies enabled?)'; $cookieTest = "\nCookie test: {$cookie}"; $contents = str_replace('{cookie}', $cookieTest, self::HTML); $response->getBody()->write($contents); return $this->cookie->withCookie($response, $cookieName, 'testing-' . \random_int(100, 200)); }
public function testGetObscuredCookie() { $cookies = Cookies::fromCookieString('testcookie1=abcde;testcookie2=12345')->with(Cookie::create('testcookie3', new OpaqueProperty('vwxyz'))); $request = $this->request->withAttribute('request_cookies', $cookies); $handler = new CookieHandler(); $cookie = $handler->getCookie($request, 'testcookie3'); $this->assertSame('vwxyz', $cookie); }