php.net |  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: 2017-10-24 06:27 UTC
Votes:2
Avg. Score:2.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: signe at cothlamadh dot net Assigned:
Status: Open Package: Documentation problem
PHP Version: Irrelevant OS: n/a
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: signe at cothlamadh dot net
New email:
PHP Version: OS:

 

 [2017-03-10 00:41 UTC] signe at cothlamadh dot net
Description:
------------
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


Patches

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

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-13 10:51 UTC] peehaa@php.net
-Assigned To: +Assigned To: peehaa
 [2017-03-13 10:51 UTC] peehaa@php.net
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] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: peehaa +Assigned To:
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC