mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-04 20:58:13 +08:00
Merge pull request #2140 from Reasno/session
fix: save session even if an exception is thrown
This commit is contained in:
commit
b5ff17eda1
@ -1,3 +1,9 @@
|
||||
# v2.0.4 - TBD
|
||||
|
||||
## Fixed
|
||||
|
||||
- [#2140](https://github.com/hyperf/hyperf/pull/2140) Fixed a case where session are not saved when exception occurs.
|
||||
|
||||
# v2.0.3 - TBD
|
||||
|
||||
## Added
|
||||
|
@ -54,16 +54,14 @@ class SessionMiddleware implements MiddlewareInterface
|
||||
|
||||
$session = $this->sessionManager->start($request);
|
||||
|
||||
$response = $handler->handle($request);
|
||||
try {
|
||||
$response = $handler->handle($request);
|
||||
} finally {
|
||||
$this->storeCurrentUrl($request, $session);
|
||||
$this->sessionManager->end($session);
|
||||
}
|
||||
|
||||
$this->storeCurrentUrl($request, $session);
|
||||
|
||||
$response = $this->addCookieToResponse($request, $response, $session);
|
||||
|
||||
// @TODO Use defer
|
||||
$this->sessionManager->end($session);
|
||||
|
||||
return $response;
|
||||
return $this->addCookieToResponse($request, $response, $session);
|
||||
}
|
||||
|
||||
private function isSessionAvailable(): bool
|
||||
|
Loading…
Reference in New Issue
Block a user