update page now

Voting

: five minus two?
(Example: nine)

The Note You're Voting On

Rumour
2 years ago
The code example provided of my_session_regenerate_id() DOES NOT work and DESTROYS all session variables. Plus the second ini_set gives an error.

The code for regenerating (only that part, the rest seems fine) should simply be this:

<?php
function my_session_regenerate_id() {
    $new_session_id = session_create_id();

    // backup session variables
    $keepSession = $_SESSION ;

    // add info for users with bad connection not receiving the new session 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     
    ini_set('session.use_strict_mode', 0);
    session_id($new_session_id);
    session_start();
    $_SESSION = $keepSession ;
}
?>

<< Back to user notes page

To Top