Skip to content

Commit 7a6871a

Browse files
Set maximal expires if session=false
Co-Authored-By: divinity76 <[email protected]>
1 parent 8a6052c commit 7a6871a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# CHANGELOG
22

33

4+
## 1.13.0 (UPCOMING)
5+
6+
* Set maximal expires value if `session=false` in `Page::setCookies`
7+
8+
49
## 1.12.0 (2024-12-09)
510

611
* Add PHP 8.4 support

src/Page.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class Page
4949
public const LOAD = 'load';
5050
public const NETWORK_IDLE = 'networkIdle';
5151

52+
private const MAX_COOKIE_AGE = 60 * 60 * 24 * 365;
53+
5254
/**
5355
* @var Target
5456
*/
@@ -1086,6 +1088,11 @@ public function setCookies($cookies)
10861088
$browserCookie['domain'] = \parse_url($this->getCurrentUrl(), \PHP_URL_HOST);
10871089
}
10881090

1091+
// set maximal expires if session=false
1092+
if (!isset($cookie['expires']) && ($cookie['session'] ?? null) === false) {
1093+
$browserCookie['expires'] = \time() + self::MAX_COOKIE_AGE;
1094+
}
1095+
10891096
$browserCookies[] = $browserCookie;
10901097
}
10911098

0 commit comments

Comments
 (0)