|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #74231 Example #2 for session_regenerate_id is broken in several ways
Submitted: 2017-03-10 00:41 UTC Modified: 2019-01-02 02:15 UTC
Avg. Score:2.4 ± 1.4
Reproduced:3 of 5 (60.0%)
Same Version:3 (100.0%)
Same OS:3 (100.0%)
From: signe at cothlamadh dot net Assigned:
Status: Open Package: Session related
PHP Version: Irrelevant OS: n/a
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-03-10 00:41 UTC] signe at cothlamadh dot net
Example #2 does carry the caveat that it's "not fully working code," however it's not just "not fully working" - it's badly broken, uses php.ini options incorrectly, and non-functional.

1. The modification of use_strict_mode is wrapping the wrong function.

use_strict_mode restricts calling session_id() with a new value.  Calling session_id() before unlocking use_strict_mode will result in a logged warning.

2. The example function does _not_ preserve any existing session data, which session_regenerate_id does.  Anyone using the example would lose all session data for the user.

Before calling session_start(), you need to store the current session data temporarily in memory, and then restore it afterward.

Documentation patch attached


session-regenerate-id.xml.diff (last revision 2017-03-10 00:42 UTC by signe at cothlamadh dot net)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-13 10:51 UTC]
-Assigned To: +Assigned To: peehaa
 [2017-03-13 10:51 UTC]
I agree that the examples on this page are badly broken.

Will try to decipher the page later somewhere during this week and try to fix it.
 [2017-10-24 06:27 UTC]
-Status: Assigned +Status: Open -Assigned To: peehaa +Assigned To:
 [2019-01-02 02:15 UTC]
-Package: Documentation problem +Package: Session related
 [2022-11-28 09:59 UTC] kinersu32 at gmail dot com
Thanks for that.
 [2022-11-29 05:36 UTC] xyz at gmail dot com
Thnaks (
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Mar 25 15:03:41 2023 UTC