コード例 #1
0
ファイル: GlobalFunctions.php プロジェクト: D66Ha/mediawiki
/**
 * 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();
}
コード例 #2
0
/**
 * Initialise php session
 *
 * @param $sessionId Bool
 */
function wfSetupSession($sessionId = false)
{
    global $wgSessionsInMemcached, $wgCookiePath, $wgCookieDomain, $wgCookieSecure, $wgCookieHttpOnly, $wgSessionHandler;
    if ($wgSessionsInMemcached) {
        if (!defined('MW_COMPILED')) {
            global $IP;
            require_once "{$IP}/includes/cache/MemcachedSessions.php";
        }
        session_set_save_handler('memsess_open', 'memsess_close', 'memsess_read', 'memsess_write', 'memsess_destroy', 'memsess_gc');
        // It's necessary to register a shutdown function to call session_write_close(),
        // because by the time the request shutdown function for the session module is
        // called, $wgMemc has already been destroyed. Shutdown functions registered
        // this way are called before object destruction.
        register_shutdown_function('memsess_write_close');
    } 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();
}
コード例 #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();
}
コード例 #4
0
ファイル: GlobalFunctions.php プロジェクト: Tjorriemorrie/app
/**
 * Initialise php session
 *
 * @param $sessionId Bool
 */
function wfSetupSession($sessionId = false)
{
    global $wgSessionsInMemcached, $wgCookiePath, $wgCookieDomain, $wgCookieSecure, $wgCookieHttpOnly, $wgSessionHandler;
    if ($wgSessionsInMemcached) {
        if (!defined('MW_COMPILED')) {
            global $IP;
            require_once "{$IP}/includes/cache/MemcachedSessions.php";
        }
        session_set_save_handler('memsess_open', 'memsess_close', 'memsess_read', 'memsess_write', 'memsess_destroy', 'memsess_gc');
        // It's necessary to register a shutdown function to call session_write_close(),
        // because by the time the request shutdown function for the session module is
        // called, $wgMemc has already been destroyed. Shutdown functions registered
        // this way are called before object destruction.
        register_shutdown_function('memsess_write_close');
    } 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();
    // Wikia change - start
    // log all sessions started with 1% sampling (PLATFORM-1266)
    if ((new Wikia\Util\Statistics\BernoulliTrial(0.01))->shouldSample()) {
        Wikia\Logger\WikiaLogger::instance()->info(__METHOD__, ['caller' => wfGetAllCallers(), 'exception' => new Exception()]);
    }
    // Wikia change - end
}