function session_cache_get_sid in Session Cache API 6
Same name and namespace in other branches
- 8 session_cache.module \session_cache_get_sid()
- 7 session_cache.module \session_cache_get_sid()
Returns an identifier for the current user session.
Typically only called when a database storage mechanism is used.
Return value
sid
2 calls to session_cache_get_sid()
- session_cache_get in ./
session_cache.module - Read data from the user session, given its bin id.
- session_cache_set in ./
session_cache.module - Write the supplied data to the user session, whatever the storage mechanism may be.
File
- ./
session_cache.module, line 126 - session_cache.module
Code
function session_cache_get_sid() {
global $user;
if (!empty($user->uid) && variable_get('session_cache_use_uid_as_sid', FALSE)) {
return 'user' . $user->uid;
// good if concurrent sessions for the same authenticated user are NOT required
}
if (empty($_COOKIE['Drupal_session_cache_sid'])) {
// Don't use core's session id. Security not a problem, so keep it short.
$sid = drupal_substr(session_id(), 0, 12);
// Don't use "global $cookie_domain", as '.localhost' is invalid!
$cookie_domain = ini_get('session.cookie_domain');
// If setcookie() fails, then everything still works, but a new session will
// be created when logging in or out.
setcookie('Drupal.session_cache.sid', $sid, session_cache_expiration_time(), '/', $cookie_domain, NULL, TRUE);
}
else {
$sid = $_COOKIE['Drupal_session_cache_sid'];
}
return $sid;
}