本文整理匯總了PHP中Magento\Framework\Session\Generic::regenerateId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Generic::regenerateId方法的具體用法?PHP Generic::regenerateId怎麽用?PHP Generic::regenerateId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\Session\Generic
的用法示例。
在下文中一共展示了Generic::regenerateId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
/**
* Initiate a session for unregistered users. Send back the session id.
*
* @return void
*/
public function execute()
{
$this->session->start('frontend');
$this->session->setUserId(0);
$this->session->setUserType(UserIdentifier::USER_TYPE_GUEST);
$this->session->regenerateId(true);
}
示例2: execute
/**
* Login registered users and initiate a session. Send back the session id.
*
* Expects a POST. ex for JSON {"username":"user@magento.com", "password":"userpassword"}
*
* @return void
*/
public function execute()
{
$contentTypeHeaderValue = $this->getRequest()->getHeader('Content-Type');
$contentType = $this->getContentType($contentTypeHeaderValue);
$loginData = null;
try {
$loginData = $this->deserializerFactory->get($contentType)->deserialize($this->getRequest()->getRawBody());
} catch (Exception $e) {
$this->getResponse()->setHttpResponseCode($e->getCode());
return;
}
if (!$loginData || $this->getRequest()->getMethod() !== \Magento\Webapi\Model\Rest\Config::HTTP_METHOD_POST) {
$this->getResponse()->setHttpResponseCode(HttpException::HTTP_BAD_REQUEST);
return;
}
$customerData = null;
try {
$customerData = $this->customerAccountService->authenticate($loginData['username'], $loginData['password']);
} catch (AuthenticationException $e) {
$this->getResponse()->setHttpResponseCode(HttpException::HTTP_UNAUTHORIZED);
return;
}
$this->session->start('frontend');
$this->session->setUserId($customerData->getId());
$this->session->setUserType(UserIdentifier::USER_TYPE_CUSTOMER);
$this->session->regenerateId(true);
}