-
Notifications
You must be signed in to change notification settings - Fork 8k
ext/session: fix cookie_lifetime overflow #21704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Girgias
merged 5 commits into
php:master
from
jorgsowa:fix/session-cookie-lifetime-overflow
Apr 20, 2026
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
29eb822
ext/session: fix cookie_lifetime overflow causing INI value desync
jorgsowa 2860ac4
validation for cookie lifetime
jorgsowa 070407c
removed unnecessary comments
jorgsowa 481e9b7
chore: modify error flow and messages of warnings
jorgsowa 83991b6
fix: return FAILURE on overflow
jorgsowa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| --TEST-- | ||
| session.cookie_lifetime overflow value is clamped | ||
| --EXTENSIONS-- | ||
| session | ||
| --SKIPIF-- | ||
| <?php include('skipif.inc'); ?> | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| ob_start(); | ||
|
|
||
| // Set a valid value first | ||
| ini_set("session.cookie_lifetime", 100); | ||
| var_dump(ini_get("session.cookie_lifetime")); | ||
|
|
||
| // Set an overflow value - should succeed with warning, value clamped | ||
| ini_set("session.cookie_lifetime", PHP_INT_MAX); | ||
| $val = (int) ini_get("session.cookie_lifetime"); | ||
| var_dump($val < PHP_INT_MAX); // clamped, not PHP_INT_MAX | ||
| var_dump($val > 0); // positive | ||
|
|
||
| // Valid values still work after clamping | ||
| ini_set("session.cookie_lifetime", 200); | ||
| var_dump(ini_get("session.cookie_lifetime")); | ||
|
|
||
| ob_end_flush(); | ||
| ?> | ||
| --EXPECTF-- | ||
| string(3) "100" | ||
|
|
||
| Warning: ini_set(): CookieLifetime value too large, value was set to the maximum of %d in %s on line %d | ||
| bool(true) | ||
| bool(true) | ||
| string(3) "200" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.