本文整理匯總了PHP中OCP\ISession::regenerateId方法的典型用法代碼示例。如果您正苦於以下問題:PHP ISession::regenerateId方法的具體用法?PHP ISession::regenerateId怎麽用?PHP ISession::regenerateId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OCP\ISession
的用法示例。
在下文中一共展示了ISession::regenerateId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: loginWithCookie
/**
* perform login using the magic cookie (remember login)
*
* @param string $uid the username
* @param string $currentToken
* @return bool
*/
public function loginWithCookie($uid, $currentToken)
{
$this->session->regenerateId();
$this->manager->emit('\\OC\\User', 'preRememberedLogin', array($uid));
$user = $this->manager->get($uid);
if (is_null($user)) {
// user does not exist
return false;
}
// get stored tokens
$tokens = OC::$server->getConfig()->getUserKeys($uid, 'login_token');
// test cookies token against stored tokens
if (!in_array($currentToken, $tokens, true)) {
return false;
}
// replace successfully used token with a new one
OC::$server->getConfig()->deleteUserValue($uid, 'login_token', $currentToken);
$newToken = OC::$server->getSecureRandom()->generate(32);
OC::$server->getConfig()->setUserValue($uid, 'login_token', $newToken, time());
$this->setMagicInCookie($user->getUID(), $newToken);
//login
$this->setUser($user);
$this->manager->emit('\\OC\\User', 'postRememberedLogin', array($user));
return true;
}
示例2: regenerateId
/**
* Wrapper around session_regenerate_id
*
* @param bool $deleteOldSession Whether to delete the old associated session file or not.
* @return void
*/
public function regenerateId($deleteOldSession = true)
{
$this->session->regenerateId($deleteOldSession);
}