浏览文章
文章信息
Maegnto2 重新生成session失效问题,Magento2 regenrate session id
13899
代码示例:
$this->session->destroy(); $this->session->regenerateId(); $this->session->logout(); if ($this->getCookieManager()->getCookie('mage-cache-sessid')) { $metadata = $this->getCookieMetadataFactory()->createCookieMetadata(); $metadata->setPath('/'); $this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata); } $this->session->setCustomerDataAsLoggedIn($customer); $this->_eventManager->dispatch('customer_data_object_login', ['customer' => $customer]); $this->_eventManager->dispatch('customer_login', ['customer' => $customer1]);理论上只需要
$this->session->logout();