Final Class Yiisoft\Cookies\CookieMiddleware
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Psr\ |
Validates and decrypts the values of the request cookie parameters,
encrypts and signs the values of the response Set-Cookie headers.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| process() | Yiisoft\ |
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| ENCRYPT | 'encrypt' | Yiisoft\ |
|
| SIGN | 'sign' | Yiisoft\ |
Method Details
| public mixed __construct ( \ | ||
| $logger | \ |
The logger instance. |
| $encryptor | Yiisoft\ |
The encryptor instance. |
| $signer | Yiisoft\ |
The signer instance. |
| $cookiesSettings | string[] |
The array keys are cookie name patterns
{@see \ For example:
|
public function __construct(
LoggerInterface $logger,
CookieEncryptor $encryptor,
CookieSigner $signer,
array $cookiesSettings = []
) {
$this->logger = $logger;
$this->encryptor = $encryptor;
$this->signer = $signer;
foreach ($cookiesSettings as $pattern => $action) {
if ($action === self::ENCRYPT) {
$this->encryption[] = (string) $pattern;
continue;
}
if ($action === self::SIGN) {
$this->signature[] = (string) $pattern;
}
}
}
| public \ | ||
| $request | \ |
|
| $handler | \ |
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$request = $this->decodeRequestCookieParams($request);
$response = $handler->handle($request);
return $this->encodeResponseSetCookieHeaders($response);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.