A few published autologin solutions, as well as SpecialUserLogin::processlogin uses the $wgUser= $u followed by $wgUser->SetCookies method similar to the below snippet to login an existing user.
When running this as a hook function, the Cookies won't set (won't login). Debug log shows $tmpuser->getID()=13 and $tmpuser->getName()='John Smith' just prior to the $wgUser=$tmpuser statement.
Cookies are enabled,
What else is needed?
Thanks for any input, Brian - - -
function AutoL(&$user) { global $sso_UN,$wgUser, $wgCommandLineMode;
if ( !$wgCommandLineMode && !isset( $_COOKIE[session_name()] ) ) { User::SetupSession(); }
//Cancel if session is current $tmpuser = User::LoadFromSession(); if($tmpuser->isLoggedIn()) return;
//Is the user already in the database? $tmpuser = User::newFromName($sso_UN);
//If exists, log them in if($tmpuser->getID() != 0) { $tmpuser->loadFromDatabase(); $wgUser = $tmpuser; $wgUser->setCookies(); $wgUser->saveSettings(); return; } }