function testStoreSessionData() { $this->dalSession->storeSerializedSession(SDATA, SESSIONID); $this->assertSessionData(); $this->dalSession->storeSerializedSession(SDATA2, SESSIONID); $actualSerializedData = $this->dalSession->getSerializedSession(SESSIONID); $this->assertEqual(SDATA2, $actualSerializedData); $prefix = OA_Dal::getTablePrefix(); $table = $this->dbh->quoteIdentifier($prefix . 'session'); $this->dbh->exec("DELETE FROM {$table}"); }
/** * Store the session array in the database */ function phpAds_SessionDataStore() { $dal = new MAX_Dal_Admin_Session(); $conf = $GLOBALS['_MAX']['CONF']; global $session; if (isset($_COOKIE['sessionID']) && $_COOKIE['sessionID'] != '') { $session_id = $_COOKIE['sessionID']; $serialized_session_data = serialize($session); $dal->storeSerializedSession($serialized_session_data, $session_id); } // Randomly purge old sessions // XXX: Why is this random? // XXX: Shouldn't this be done by a daemon, or at least at logout time? srand((double) microtime() * 1000000); if (rand(1, 100) == 42) { $dal->pruneOldSessions(); } }
/** * Store the session array in the database */ function phpAds_SessionDataStore() { global $session; $dal = new MAX_Dal_Admin_Session(); if (isset($_COOKIE['sessionID']) && $_COOKIE['sessionID'] != '') { $session_id = $_COOKIE['sessionID']; $serialized_session_data = serialize($session); $dal->storeSerializedSession($serialized_session_data, $session_id); } // Garbage collect old sessions, 1 out of 100 requests, roughly if (mt_rand(1, 100) == 42) { $dal->pruneOldSessions(); } }