public function SessionProxy_Storage_Database::write in Session Proxy 7
Overrides SessionProxy_Storage_Interface::write
File
- lib/
SessionProxy/ Storage/ Database.php, line 35
Class
Code
public function write($sessionId, $serializedData) {
try {
// For performance reasons, do not update the sessions table, unless
// $_SESSION has changed or more than 180 has passed since the last update.
if ($this
->sessionDataHasChanged($sessionId, $serializedData)) {
// Either ssid or sid or both will be added from $key below.
$fields = array(
'uid' => $this->uid,
'cache' => 0,
'hostname' => ip_address(),
'session' => $serializedData,
'timestamp' => REQUEST_TIME,
);
$key = array(
'sid' => $sessionId,
'ssid' => '',
);
db_merge('sessions')
->key($key)
->fields($fields)
->execute();
}
return TRUE;
} catch (Exception $exception) {
// FIXME: This should never be here, a global try/catch should definitely
// be done upper in the code.
require_once DRUPAL_ROOT . '/includes/errors.inc';
// If we are displaying errors, then do so with no possibility of a further
// uncaught exception being thrown.
if (error_displayable()) {
print '<h1>Uncaught exception thrown in session handler.</h1>';
print '<p>' . _drupal_render_exception_safe($exception) . '</p><hr />';
}
return FALSE;
}
}