菜单

typo3用户自动登录

2011年04月21日 - typo3

Typo3 4,5,6

$loginData = array(
'uname' => $user['username'], //usernmae
'uident' => $user['password'], //password (加密后)
'status' => 'login'
);
$GLOBALS['TSFE']->fe_user->checkPid=0; //do not use a particular pid
$info= $GLOBALS['TSFE']->fe_user->getAuthInfoArray();
$user2=$GLOBALS['TSFE']->fe_user->fetchUserRecord($info['db_user'],$loginData['uname']);
//print_r($user2);
$ok=$GLOBALS['TSFE']->fe_user->compareUident($user2,$loginData);
if($ok) {
//login successfull
$GLOBALS['TSFE']->fe_user->createUserSession($user2);
$GLOBALS["TSFE"]->fe_user->loginSessionStarted = TRUE;
$GLOBALS["TSFE"]->fe_user->user = $GLOBALS["TSFE"]->fe_user->fetchUserSession();
}

Typo3 7

$GLOBALS['TSFE']->fe_user->createUserSession($userinfo);
$GLOBALS['TSFE']->fe_user->setAndSaveSessionData('login', 'success');

发表评论

电子邮件地址不会被公开。 必填项已用*标注