|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #74309 example2 is missing old session data backup
Submitted: 2017-03-24 15:01 UTC Modified: 2019-01-02 00:39 UTC
Avg. Score:2.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: bburnichon at gmail dot com Assigned:
Status: Open Package: Session related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-03-24 15:01 UTC] bburnichon at gmail dot com
From manual page:

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;

    // Start session with new session ID
    ini_set('session.use_strict_mode', 0);
    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;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-02 00:39 UTC]
-Package: Documentation problem +Package: Session related
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 07:01:31 2024 UTC