Skip to content

Commit b825756

Browse files
authored
Update expires format for session cookie (#9304)
* Update expires format for session cookie see GH-9200 see 15e3fcb * Add ext/session/tests/gh9200.phpt
1 parent 438f692 commit b825756

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ PHP NEWS
2323
. Added extension specific Exceptions/Errors (RandomException, RandomError,
2424
BrokenRandomEngineError). (timwolla)
2525

26+
- Session:
27+
. Fixed GH-9200 (setcookie has an obsolete expires date format). (timwolla)
28+
2629
- Standard:
2730
. Fixed bug #65489 (glob() basedir check is inconsistent). (Jakub Zelenka)
2831
. Fixed GH-9200 (setcookie has an obsolete expires date format). (Derick)

ext/session/session.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ static zend_result php_session_send_cookie(void) /* {{{ */
13451345
t = tv.tv_sec + PS(cookie_lifetime);
13461346

13471347
if (t > 0) {
1348-
date_fmt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, t, 0);
1348+
date_fmt = php_format_date("D, d M Y H:i:s \\G\\M\\T", sizeof("D, d M Y H:i:s \\G\\M\\T")-1, t, 0);
13491349
smart_str_appends(&ncookie, COOKIE_EXPIRES);
13501350
smart_str_appendl(&ncookie, ZSTR_VAL(date_fmt), ZSTR_LEN(date_fmt));
13511351
zend_string_release_ex(date_fmt, 0);

ext/session/tests/gh9200.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
GH-9200: setcookie has an obsolete expires date format
3+
--INI--
4+
session.cookie_lifetime=3600
5+
--EXTENSIONS--
6+
session
7+
--CGI--
8+
--FILE--
9+
<?php
10+
session_name("foo");
11+
session_id('bar');
12+
session_start();
13+
14+
foreach (headers_list() as $header) {
15+
if (preg_match('/^Set-Cookie: foo=bar; expires=(Mon|Tue|Wed|Thu|Fri|Sat|Sun), [0-9][0-9] (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) 2[0-9][0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] GMT; Max-Age=3600; path=\\/$/', $header)) {
16+
echo "Success", PHP_EOL;
17+
exit;
18+
}
19+
}
20+
echo "Fail", PHP_EOL;
21+
?>
22+
--EXPECT--
23+
Success

0 commit comments

Comments
 (0)