public static function write($session_id, $data) { // encryption $crypt = new Crypt(); $data = $crypt->encrypt($data); $sessions = new Sessions(); $sessions->session_id = $session_id; $sessions->data = $data; $s = $sessions->where("session_id = ?", $session_id)->find(); if (is_null($s)) { return $sessions->save(); } $sessions->id = $s->id; return $sessions->update(); }
public function write($id, $value) { $sessions_table = new Sessions(); $lifetime = (int) Bolts_Registry::get('session_timeout'); $expiration = time() + $lifetime; $data = array('id' => $id, 'value' => $value, 'expiration' => $expiration); $where = $sessions_table->getAdapter()->quoteInto('id = ?', $id); if ($sessions_table->getCountByWhereClause($where) > 0) { $sessions_table->update($data, $where); } else { $id = $sessions_table->insert($data); } }