コード例 #1
0
 function testPruneOldSessions()
 {
     $this->generateSession();
     $this->dalSession->pruneOldSessions();
     $this->assertSessionData();
     $this->outdateSession();
     $actualSerializedData = $this->dalSession->getSerializedSession(SESSIONID);
     $this->assertFalse($actualSerializedData, 'The serialized data is false for non-existent session id.');
     $this->dalSession->pruneOldSessions();
     $prefix = OA_Dal::getTablePrefix();
     $table = $this->dbh->quoteIdentifier($prefix . 'session');
     $cSessions = $this->dbh->queryOne("SELECT count(*) AS c FROM {$table}");
     $this->assertEqual(0, $cSessions);
 }
コード例 #2
0
/**
 * 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();
    }
}
コード例 #3
0
/**
 * 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();
    }
}