Run SessionHandler::write() into a transaction
This commit is contained in:
@@ -54,17 +54,23 @@ class SessionHandler implements SessionHandlerInterface
|
|||||||
{
|
{
|
||||||
$lifetime = time() + (ini_get('session.gc_maxlifetime') ?: 1440);
|
$lifetime = time() + (ini_get('session.gc_maxlifetime') ?: 1440);
|
||||||
|
|
||||||
|
$this->db->startTransaction();
|
||||||
|
|
||||||
if ($this->db->table(self::TABLE)->eq('id', $sessionID)->exists()) {
|
if ($this->db->table(self::TABLE)->eq('id', $sessionID)->exists()) {
|
||||||
return $this->db->table(self::TABLE)->eq('id', $sessionID)->update(array(
|
$this->db->table(self::TABLE)->eq('id', $sessionID)->update([
|
||||||
'expire_at' => $lifetime,
|
'expire_at' => $lifetime,
|
||||||
'data' => $data,
|
'data' => $data,
|
||||||
));
|
]);
|
||||||
}
|
} else {
|
||||||
|
$this->db->table(self::TABLE)->insert([
|
||||||
return $this->db->table(self::TABLE)->insert(array(
|
|
||||||
'id' => $sessionID,
|
'id' => $sessionID,
|
||||||
'expire_at' => $lifetime,
|
'expire_at' => $lifetime,
|
||||||
'data' => $data,
|
'data' => $data,
|
||||||
));
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->closeTransaction();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user