Skip to content

Commit ece77bf

Browse files
committed
Session: by default uses sameSite: Lax (BC break)
1 parent af08358 commit ece77bf

4 files changed

Lines changed: 5 additions & 4 deletions

File tree

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
// cookies
4040
'cookie_lifetime' => 0, // until the browser is closed
4141
'cookie_httponly' => true, // must be enabled to prevent Session Hijacking
42+
'cookie_samesite' => 'Lax',// must be enabled to prevent CSRF
4243

4344
// other
4445
'gc_maxlifetime' => self::DEFAULT_FILE_LIFETIME, // 3 hours

tests/Http/Session.cookies.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Assert::same([
2525
'use_trans_sid' => 0,
2626
'cookie_lifetime' => 0,
2727
'cookie_httponly' => true,
28+
'cookie_samesite' => 'Lax',
2829
'gc_maxlifetime' => 10800,
2930
'cookie_path' => '/user/',
3031
'cookie_domain' => 'nette.org',

tests/Http/Session.sameSite.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ if (PHP_SAPI === 'cli') {
1515
$factory = new Nette\Http\RequestFactory;
1616
$session = new Nette\Http\Session($factory->createHttpRequest(), new Nette\Http\Response);
1717

18-
$session->setOptions([
19-
'cookie_samesite' => 'Lax',
20-
]);
21-
2218
$session->start();
2319

2420
Assert::contains(

tests/Http/Session.setOptions.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Assert::same([
2222
'use_trans_sid' => 0,
2323
'cookie_lifetime' => 0,
2424
'cookie_httponly' => true,
25+
'cookie_samesite' => 'Lax',
2526
'gc_maxlifetime' => 10800,
2627
'cookie_path' => '/',
2728
'cookie_domain' => '',
@@ -39,6 +40,7 @@ Assert::same([
3940
'use_trans_sid' => 0,
4041
'cookie_lifetime' => 0,
4142
'cookie_httponly' => true,
43+
'cookie_samesite' => 'Lax',
4244
'gc_maxlifetime' => 10800,
4345
'cookie_path' => '/',
4446
'cookie_secure' => false,
@@ -55,6 +57,7 @@ Assert::same([
5557
'use_trans_sid' => 0,
5658
'cookie_lifetime' => 0,
5759
'cookie_httponly' => true,
60+
'cookie_samesite' => 'Lax',
5861
'gc_maxlifetime' => 10800,
5962
'cookie_path' => '/',
6063
'cookie_secure' => false,

0 commit comments

Comments
 (0)