Skip to content

Commit 2147863

Browse files
committed
Session: default sameSite is 'Lax' (BC break)
1 parent 0759b83 commit 2147863

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

src/Http/Session.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class Session
3939

4040
/** @var array default configuration */
4141
private $options = [
42+
'cookie_samesite' => IResponse::SAME_SITE_LAX,
4243
'cookie_lifetime' => 0, // for a maximum of 3 hours or until the browser is closed
4344
'gc_maxlifetime' => self::DEFAULT_FILE_LIFETIME, // 3 hours
4445
];

tests/Http.DI/SessionExtension.cookieSecure.auto.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ test('', function () {
3737

3838
Assert::same(
3939
PHP_VERSION_ID >= 70300
40-
? ['lifetime' => 0, 'path' => '/', 'domain' => '', 'secure' => false, 'httponly' => true, 'samesite' => '']
41-
: ['lifetime' => 0, 'path' => '/', 'domain' => '', 'secure' => false, 'httponly' => true],
40+
? ['lifetime' => 0, 'path' => '/', 'domain' => '', 'secure' => false, 'httponly' => true, 'samesite' => 'Lax']
41+
: ['lifetime' => 0, 'path' => '/; SameSite=Lax', 'domain' => '', 'secure' => false, 'httponly' => true],
4242
session_get_cookie_params()
4343
);
4444
});
@@ -66,8 +66,8 @@ test('', function () {
6666

6767
Assert::same(
6868
PHP_VERSION_ID >= 70300
69-
? ['lifetime' => 0, 'path' => '/', 'domain' => '', 'secure' => true, 'httponly' => true, 'samesite' => '']
70-
: ['lifetime' => 0, 'path' => '/', 'domain' => '', 'secure' => true, 'httponly' => true],
69+
? ['lifetime' => 0, 'path' => '/', 'domain' => '', 'secure' => true, 'httponly' => true, 'samesite' => 'Lax']
70+
: ['lifetime' => 0, 'path' => '/; SameSite=Lax', 'domain' => '', 'secure' => true, 'httponly' => true],
7171
session_get_cookie_params()
7272
);
7373
});

tests/Http/Session.cookies.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ $response->cookieDomain = 'nette.org';
1919
$response->cookieSecure = true;
2020

2121
Assert::same([
22+
'cookie_samesite' => 'Lax',
2223
'cookie_lifetime' => 0,
2324
'gc_maxlifetime' => 10800,
2425
'cookie_path' => '/user/',

tests/Http/Session.setOptions.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ $factory = new Nette\Http\RequestFactory;
1616
$session = new Nette\Http\Session($factory->fromGlobals(), new Nette\Http\Response);
1717

1818
Assert::same([
19+
'cookie_samesite' => 'Lax',
1920
'cookie_lifetime' => 0,
2021
'gc_maxlifetime' => 10800,
2122
'cookie_path' => '/',
@@ -28,6 +29,7 @@ $session->setOptions([
2829
]);
2930
Assert::same([
3031
'cookie_domain' => '.domain.com',
32+
'cookie_samesite' => 'Lax',
3133
'cookie_lifetime' => 0,
3234
'gc_maxlifetime' => 10800,
3335
'cookie_path' => '/',
@@ -39,6 +41,7 @@ $session->setOptions([
3941
]);
4042
Assert::same([
4143
'cookie_domain' => '.domain.org',
44+
'cookie_samesite' => 'Lax',
4245
'cookie_lifetime' => 0,
4346
'gc_maxlifetime' => 10800,
4447
'cookie_path' => '/',

0 commit comments

Comments
 (0)