Final Class Yiisoft\Session\SessionMiddleware
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Psr\ |
Session middleware handles storing session ID into a response cookie and restoring the session associated with the ID from a request cookie.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| process() | Yiisoft\ |
Method Details
| public mixed __construct ( Yiisoft\ | ||
| $session | Yiisoft\ |
|
public function __construct(private SessionInterface $session) {}
| public \ | ||
| $request | \ |
|
| $handler | \ |
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$requestSessionId = $this->getSessionIdFromRequest($request);
if ($requestSessionId !== null && $this->session->getId() === null) {
$this->session->setId($requestSessionId);
}
try {
$response = $handler->handle($request);
} catch (Throwable $e) {
$this->session->discard();
throw $e;
}
return $this->commitSession($request, $response);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.