function drupal_session_regenerate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 modules/memcache/unstable/memcache-session.inc \drupal_session_regenerate()
Called when an anonymous user becomes authenticated or vice-versa.
Related topics
File
- modules/
memcache/ unstable/ memcache-session.inc, line 269
Code
function drupal_session_regenerate() {
global $user;
if (drupal_session_started()) {
$old_session_id = session_id();
session_regenerate_id();
$new_session_id = session_id();
}
else {
// Start the session when it doesn't exist yet.
// Preserve the logged in user, as it will be reset to anonymous
// by _drupal_session_read.
$account = $user;
drupal_session_start();
$user = $account;
}
if (isset($old_session_id)) {
$info = dmemcache_get($old_session_id, 'session');
$info->sid = $new_session_id;
dmemcache_set($new_session_id, $info, ini_get('session.gc_maxlifetime'), 'session');
// Clear the old data from the cache.
dmemcache_delete($old_session_id, 'session');
}
date_default_timezone_set(drupal_get_user_timezone());
}