Skip to content

Commit

Permalink
Allow the SameSite option to be configured for lumberjack_session cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
adamtomat committed Aug 16, 2021
1 parent d877406 commit 7dc3466
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/Providers/SessionServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,19 @@ public function boot()

add_action('send_headers', function () use (&$cookieSet) {
if (!$cookieSet) {
$cookieOptions = [
'lifetime' => Config::get('session.lifetime', 120),
'path' => Config::get('session.path', '/'),
'domain' => Config::get('session.domain', null),
'secure' => Config::get('session.secure', false),
'httpOnly' => Config::get('session.http_only', true),
];
$lifetime = Config::get('session.lifetime', 120);

setcookie(
$this->session->getName(),
$this->session->getId(),
time() + ($cookieOptions['lifetime'] * 60),
$cookieOptions['path'],
$cookieOptions['domain'],
$cookieOptions['secure'],
$cookieOptions['httpOnly']
[
'expires' => time() + ($lifetime * 60),
'path' => Config::get('session.path', '/'),
'domain' => Config::get('session.domain', null),
'secure' => Config::get('session.secure', false),
'httponly' => Config::get('session.http_only', true),
'samesite' => Config::get('session.same_site', 'strict'),
]
);

$cookieSet = true;
Expand Down

0 comments on commit 7dc3466

Please sign in to comment.