예제 #1
0
/**
 * Initialise php session
 *
 * @param bool $sessionId
 */
function wfSetupSession($sessionId = false)
{
    global $wgSessionsInMemcached, $wgSessionsInObjectCache, $wgCookiePath, $wgCookieDomain, $wgCookieSecure, $wgCookieHttpOnly, $wgSessionHandler;
    if ($wgSessionsInObjectCache || $wgSessionsInMemcached) {
        ObjectCacheSessionHandler::install();
    } elseif ($wgSessionHandler && $wgSessionHandler != ini_get('session.save_handler')) {
        # Only set this if $wgSessionHandler isn't null and session.save_handler
        # hasn't already been set to the desired value (that causes errors)
        ini_set('session.save_handler', $wgSessionHandler);
    }
    session_set_cookie_params(0, $wgCookiePath, $wgCookieDomain, $wgCookieSecure, $wgCookieHttpOnly);
    session_cache_limiter('private, must-revalidate');
    if ($sessionId) {
        session_id($sessionId);
    } else {
        wfFixSessionID();
    }
    MediaWiki\suppressWarnings();
    session_start();
    MediaWiki\restoreWarnings();
}
 /**
  * Callback when reading session data.
  *
  * @param string $id Session id
  * @return mixed Session data
  */
 static function read($id)
 {
     $data = self::getCache()->get(self::getKey($id));
     self::$hashCache = array($id => self::getHash($data));
     return $data === false ? '' : $data;
 }
예제 #3
0
/**
 * Initialise php session
 *
 * @param $sessionId Bool
 */
function wfSetupSession($sessionId = false)
{
    global $wgSessionsInMemcached, $wgSessionsInObjectCache, $wgCookiePath, $wgCookieDomain, $wgCookieSecure, $wgCookieHttpOnly, $wgSessionHandler;
    if ($wgSessionsInObjectCache || $wgSessionsInMemcached) {
        ObjectCacheSessionHandler::install();
    } elseif ($wgSessionHandler && $wgSessionHandler != ini_get('session.save_handler')) {
        # Only set this if $wgSessionHandler isn't null and session.save_handler
        # hasn't already been set to the desired value (that causes errors)
        ini_set('session.save_handler', $wgSessionHandler);
    }
    $httpOnlySafe = wfHttpOnlySafe() && $wgCookieHttpOnly;
    wfDebugLog('cookie', 'session_set_cookie_params: "' . implode('", "', array(0, $wgCookiePath, $wgCookieDomain, $wgCookieSecure, $httpOnlySafe)) . '"');
    session_set_cookie_params(0, $wgCookiePath, $wgCookieDomain, $wgCookieSecure, $httpOnlySafe);
    session_cache_limiter('private, must-revalidate');
    if ($sessionId) {
        session_id($sessionId);
    } else {
        wfFixSessionID();
    }
    wfSuppressWarnings();
    session_start();
    wfRestoreWarnings();
}
 /**
  * Callback when reading session data.
  *
  * @param string $id Session id
  * @return mixed Session data
  */
 static function read($id)
 {
     $stime = microtime(true);
     $data = self::getCache()->get(self::getKey($id));
     $real = microtime(true) - $stime;
     RequestContext::getMain()->getStats()->timing("session.read", 1000 * $real);
     self::$hashCache = array($id => self::getHash($data));
     return $data === false ? '' : $data;
 }