Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 066d052

Browse files
committed
move reset session and cookie to sandbox
1 parent 03ae3f5 commit 066d052

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

src/Server/Application.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -278,20 +278,6 @@ public function terminate(Request $request, $response)
278278
protected function terminateLaravel(Request $request, $response)
279279
{
280280
$this->getKernel()->terminate($request, $response);
281-
282-
// clean laravel session
283-
if ($request->hasSession()) {
284-
$session = $request->getSession();
285-
$session->flush();
286-
}
287-
288-
// clean laravel cookie queue
289-
if (isset($this->application['cookie'])) {
290-
$cookies = $this->application['cookie'];
291-
foreach ($cookies->getQueuedCookies() as $name => $cookie) {
292-
$cookies->unqueue($name);
293-
}
294-
}
295281
}
296282

297283
/**

src/Server/Sandbox.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ public function getApplication()
107107
protected function resetLaravelApp($application)
108108
{
109109
$this->resetConfigInstance($application);
110+
$this->resetSession($application);
111+
$this->resetCookie($application);
110112
$this->clearInstances($application);
111113
$this->rebindRouterContainer($application);
112114
$this->rebindViewContainer($application);
@@ -131,6 +133,29 @@ protected function resetConfigInstance($application)
131133
$application->instance('config', clone $this->config);
132134
}
133135

136+
/**
137+
* Reset laravel's session data.
138+
*/
139+
protected function resetSession($application)
140+
{
141+
if (isset($application['session'])) {
142+
$session = $application->make('session');
143+
$session->flush();
144+
}
145+
}
146+
147+
/**
148+
* Reset laravel's cookie.
149+
*/
150+
protected function resetCookie($application)
151+
{
152+
if (isset($application['cookie'])) {
153+
foreach ($application->make('cookie')->getQueuedCookies() as $key => $value) {
154+
$cookies->unqueue($key);
155+
}
156+
}
157+
}
158+
134159
/**
135160
* Rebind laravel's container in router.
136161
*/

0 commit comments

Comments
 (0)