Skip to content

Commit 7dc3466

Browse files
authored
Allow the SameSite option to be configured for lumberjack_session cookie
1 parent d877406 commit 7dc3466

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/Providers/SessionServiceProvider.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,19 @@ public function boot()
3333

3434
add_action('send_headers', function () use (&$cookieSet) {
3535
if (!$cookieSet) {
36-
$cookieOptions = [
37-
'lifetime' => Config::get('session.lifetime', 120),
38-
'path' => Config::get('session.path', '/'),
39-
'domain' => Config::get('session.domain', null),
40-
'secure' => Config::get('session.secure', false),
41-
'httpOnly' => Config::get('session.http_only', true),
42-
];
36+
$lifetime = Config::get('session.lifetime', 120);
4337

4438
setcookie(
4539
$this->session->getName(),
4640
$this->session->getId(),
47-
time() + ($cookieOptions['lifetime'] * 60),
48-
$cookieOptions['path'],
49-
$cookieOptions['domain'],
50-
$cookieOptions['secure'],
51-
$cookieOptions['httpOnly']
41+
[
42+
'expires' => time() + ($lifetime * 60),
43+
'path' => Config::get('session.path', '/'),
44+
'domain' => Config::get('session.domain', null),
45+
'secure' => Config::get('session.secure', false),
46+
'httponly' => Config::get('session.http_only', true),
47+
'samesite' => Config::get('session.same_site', 'strict'),
48+
]
5249
);
5350

5451
$cookieSet = true;

0 commit comments

Comments
 (0)