/** * Initialize session */ static function init($sessionid = false) { if (empty($sessionid)) { HTTP_Session::start(null, null); $sessionid = HTTP_Session::id(); } else { HTTP_Session::start(null, $sessionid); } if (HTTP_Session::isIdle() || HTTP_Session::isExpired()) { return false; } return $sessionid; }
function start($name = 'SessionID', $id = null) { HTTP_Session::name($name); if (is_null(SASession::detectID())) { HTTP_Session::id($id ? $id : uniqid(dechex(rand()))); } session_start(); if (!isset($_SESSION['__HTTP_Session_Info'])) { $_SESSION['__HTTP_Session_Info'] = HTTP_SESSION_STARTED; } else { $_SESSION['__HTTP_Session_Info'] = HTTP_SESSION_CONTINUED; } }
/** * Replicate session data to table specified in option 'replicateBeforeDestroy' * * @param string $targetTable Table to replicate to * @param string $id Id of record to replicate * * @access private * @return bool */ function replicate($targetTable, $id = null) { if (is_null($id)) { $id = HTTP_Session::id(); } // Check if table row already exists $query = sprintf("SELECT COUNT(id) FROM %s WHERE id = %s", $targetTable, $this->db->quoteSmart(md5($id))); $result = $this->db->getOne($query); if (DB::isError($result)) { new DB_Error($result->code, PEAR_ERROR_DIE); return false; } // Insert new row into dest table if (0 == intval($result)) { $query = sprintf("INSERT INTO %s SELECT * FROM %s WHERE id = %s", $targetTable, $this->options['table'], $this->db->quoteSmart(md5($id))); } else { // Update existing row $query = sprintf("UPDATE %s dst, %s src SET dst.expiry = src.expiry, dst.data = src.data WHERE dst.id = src.id AND src.id = %s", $targetTable, $this->options['table'], $this->db->quoteSmart(md5($id))); } $result = $this->db->query($query); if (DB::isError($result)) { new DB_Error($result->code, PEAR_ERROR_DIE); return false; } return true; }
function getSessionId() { return HTTP_Session::id(); }