summaryrefslogtreecommitdiff
path: root/app/Core/Session/SessionHandler.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2018-02-13 15:06:51 -0800
committerFrédéric Guillot <fred@kanboard.net>2018-02-13 15:06:51 -0800
commitb096e907cf003659cf1b504787363352191fc639 (patch)
treefc33ed8948ebfae13c93459343e09ff6f930d32e /app/Core/Session/SessionHandler.php
parent2c4a3cb7e0b767c3a7ef8887e18541044ae1cff2 (diff)
Run SessionHandler::write() into a transaction
Diffstat (limited to 'app/Core/Session/SessionHandler.php')
-rw-r--r--app/Core/Session/SessionHandler.php20
1 files changed, 13 insertions, 7 deletions
diff --git a/app/Core/Session/SessionHandler.php b/app/Core/Session/SessionHandler.php
index 135e0ab0..df32a74e 100644
--- a/app/Core/Session/SessionHandler.php
+++ b/app/Core/Session/SessionHandler.php
@@ -54,17 +54,23 @@ class SessionHandler implements SessionHandlerInterface
{
$lifetime = time() + (ini_get('session.gc_maxlifetime') ?: 1440);
+ $this->db->startTransaction();
+
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,
+ 'data' => $data,
+ ]);
+ } else {
+ $this->db->table(self::TABLE)->insert([
+ 'id' => $sessionID,
'expire_at' => $lifetime,
'data' => $data,
- ));
+ ]);
}
- return $this->db->table(self::TABLE)->insert(array(
- 'id' => $sessionID,
- 'expire_at' => $lifetime,
- 'data' => $data,
- ));
+ $this->db->closeTransaction();
+
+ return true;
}
}