Doc #74309 [NEW]: example2 is missing old session data backup
| From: | bburnichon at gmail dot com | Date: | Fri, 24 Mar 2017 15:01:51 +0000 |
| Subject: | Doc #74309 [NEW]: example2 is missing old session data backup | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-14537@lists.php.net to get a copy of this message | ||
From: bburnichon at gmail dot com
Operating system:
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:example2 is missing old session data backup
Description:
------------
---
From manual page: http://www.php.net/function.session-regenerate-id
---
Currently, in the new session, data is lost.
function my_session_regenerate_id() {
// Backup data to allow later restore
$old_session_data = $_SESSION;
// New session ID is required to set proper session ID
// when session ID is not set due to unstable network.
$new_session_id = session_create_id();
$_SESSION['new_session_id'] = $new_session_id;
// Set destroy timestamp
$_SESSION['destroyed'] = time();
// Write and close current session;
session_commit();
// Start session with new session ID
session_id($new_session_id);
ini_set('session.use_strict_mode', 0);
session_start();
ini_set('session.use_strict_mode', 1);
// Restore data from old session as session_start created a new
array reference in $_SESSION
$_SESSION = $old_session_data;
}
--
Edit bug report at https://bugs.php.net/bug.php?id=74309&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74309&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74309&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74309&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74309&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74309&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74309&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74309&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74309&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74309&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74309&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74309&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74309&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74309&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74309&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74309&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74309&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74309&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74309&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74309&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74309&r=mysqlcfg