Working on mediawiki project facing the issue of frequent logouts where user when login and try some edit and update operation then after spending few minutes users gets automatically signout and redirects it to login page.
I have tried the following approaches added in LocalSettings.php but none of them works-
APPROACH-1
$wgMainCacheType = CACHE_ACCEL; $wgSessionCacheType = CACHE_DB;
APPROACH-2
$wgSessionTimeout = 604800; $wgCachePages = false;
APPROACH-3
ini_set('session.gc_maxlifetime', 604800); session_set_cookie_params(604800); session_start();
APPROACH-4
$wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', time() ) ); header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 3600 ) . ' GMT' ); header( 'Cache-Control: public, max-age=3600' );
APPROACH-5
$wgParserCacheType = CACHE_NONE; $wgCachePages = false;
I have also used one approach where i have go inside the docker and commented out the following code in mediawiki/includes/Setup.php which is somehow works but triggered one more issue.
if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
// If session.auto_start is there, we can't touch session name
if ( $wgPHPSessionHandling !== 'disable' && !wfIniGetBool( 'session.auto_start' ) ){
session_name($wgSessionName ?: $wgCookiePrefix . '_session');
HeaderCallback::warnIfHeadersSent();
}
//Create the SessionManager singleton and set up our session handler,
// unless we're specifically asked not to.
if ( !defined( 'MW_NO_SESSION_HANDLER' ) ) {
MediaWiki\Session\PHPSessionHandler::install(
MediaWiki\Session\SessionManager::singleton()
);
}
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
// Initialize the session
try {
$session = MediaWiki\Session\SessionManager::getGlobalSession();
} catch ( MediaWiki\Session\SessionOverflowException $ex ) {
// The exception is because the request had multiple possible
// sessions tied for top priority. Report this to the user.
$list = [];
foreach ( $ex->getSessionInfos() as $info ) {
$list[] = $info->getProvider()->describe( $contLang );
}
$list = $contLang->listToText( $list );
throw new HttpError( 400,
Message::newFromKey( 'sessionmanager-tie', $list )->inLanguage( $contLang )
);
}
unset( $contLang );
if ( $session->isPersistent() ) {
$wgInitialSessionId = $session->getSessionId();
}
$session->renew();
if ( MediaWiki\Session\PHPSessionHandler::isEnabled() &&
( $session->isPersistent() || $session->shouldRememberUser() ) &&
session_id() !== $session->getId()
) {
// Start the PHP-session for backwards compatibility
if ( session_id() !== '' ) {
wfDebugLog( 'session', 'PHP session {old_id} was already started, changing to {new_id}', 'all', [
'old_id' => session_id(),
'new_id' => $session->getId(),
] );
session_write_close();
}
session_id( $session->getId() );
session_start();
}
unset( $session );
} else {
// Even if we didn't set up a global Session, still install our session
// handler unless specifically requested not to.
if ( !defined( 'MW_NO_SESSION_HANDLER' ) ) {
MediaWiki\Session\PHPSessionHandler::install(
MediaWiki\Session\SessionManager::singleton()
);
}
}
After removing the above code frequent logouts problem is solved in mediawiki project.
after removing the above code inside Setup.php
Can anyone assist here?