/** * Read session data * * @param string $sess_id session ID * * @return mixed session data if exist, false otherwise */ public function read($sess_id) { $session = $this->query('hGetAll', $this->id($sess_id)); if (!empty($session)) { if ($session['expiry'] > TIME) { return $session['data']; } else { // the session did not have time to get in "stored_sessions" and got out of date, it is necessary to return only settings $this->delete($sess_id); $session = Session::decode($session['data']); return Session::encode(array('settings' => !empty($session['settings']) ? $session['settings'] : array())); } } return false; }
/** * Read session data * * @param string $sess_id session ID * * @return mixed session data if exist, false otherwise */ public function read($sess_id) { $session = db_get_row('SELECT * FROM ?:sessions WHERE session_id = ?s', $sess_id); if (!empty($session)) { if ($session['expiry'] > TIME) { return $session['data']; } else { // the session did not have time to get in "stored_sessions" and got out of date, it is necessary to return only settings db_query('DELETE FROM ?:sessions WHERE session_id = ?s', $sess_id); $session = Session::decode($session['data']); return Session::encode(array('settings' => !empty($session['settings']) ? $session['settings'] : array())); } } return false; }
/** * Read session data * * @param string $sess_id session ID * * @return mixed session data if exist, false otherwise */ public function read($sess_id) { $session = db_get_row('SELECT * FROM ?:sessions WHERE session_id = ?s', $sess_id); if (empty($session) || $session['expiry'] < TIME) { if (!empty($session)) { // the session did not have time to get in "stored_sessions" and got out of date, it is necessary to return only settings db_query('DELETE FROM ?:sessions WHERE session_id = ?s', $sess_id); $session = Session::decode($session['data']); return Session::encode(array('settings' => !empty($session['settings']) ? $session['settings'] : array())); } $stored_data = db_get_field('SELECT data FROM ?:stored_sessions WHERE session_id = ?s', $sess_id); if (!empty($stored_data)) { db_query('DELETE FROM ?:stored_sessions WHERE session_id = ?s', $sess_id); $current = array(); $_stored = Session::decode($stored_data); $_current['settings'] = !empty($_stored['settings']) ? $_stored['settings'] : array(); return Session::encode($_current); } } else { return $session['data']; } return false; }