function _drupal_session_regenerate_existing

Regenerates an existing session.

1 call to _drupal_session_regenerate_existing()
drupal_session_regenerate in includes/session.inc
Called when an anonymous user becomes authenticated or vice-versa.

File

includes/session.inc, line 459

Code

function _drupal_session_regenerate_existing() {
    global $user;
    // Preserve existing settings for the saving of sessions.
    $original_save_session_status = drupal_save_session();
    // Turn off saving of sessions.
    drupal_save_session(FALSE);
    session_write_close();
    drupal_session_started(FALSE);
    // Preserve the user object, as starting a new session will reset it.
    $original_user = $user;
    session_id(drupal_random_key());
    drupal_session_start();
    $user = $original_user;
    // Restore the original settings for the saving of sessions.
    drupal_save_session($original_save_session_status);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.