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; } }
Further debugging reveals that cookies are indeed 'set', meaning that a print_r($_COOKIE); outputs values for
[SSOLanguage] => en [SSOCookie] => 3b84iei838ei... [wikidbUserID] => 13 [wikidbUserName] => John Smith 123 [PHPSESSID] => njg7rnovlc8l...
So why won't the login 'stick'?
bc
On 5/24/06, Brian Carpenter hopespoppa@gmail.com wrote:
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; }
}
mediawiki-l@lists.wikimedia.org