Magento会话过期后设置默认商店视图
问题描述:
How can I set programmatically or redirect the user after the session expired? In login the user is redirected to a specified store view. This store view is available only for the logged in users. when the session expired I would redirect the user the default store view.
如何在会话过期后以编程方式设置或重定向用户? 在登录时,用户被重定向到指定的商店视图。 此商店视图仅适用于已登录的用户。 当会话过期时,我会将用户重定向到默认的商店视图。 p> div>
答
I modified the Core/Model/App.php _checkCookieStore method
protected function _checkCookieStore($type)
{
if (!$this->getCookie()->get()) {
return $this;
}
$session = Mage::getSingleton('customer/session', array('name'=>'frontend'));
if (!$session->isLoggedIn()) {
unset($_COOKIE['store']);
}
$store = $this->getCookie()->get(Mage_Core_Model_Store::COOKIE_NAME);
if ($store && isset($this->_stores[$store])
&& $this->_stores[$store]->getId()
&& $this->_stores[$store]->getIsActive()) {
if ($type == 'website'
&& $this->_stores[$store]->getWebsiteId() == $this->_stores[$this->_currentStore]->getWebsiteId()) {
$this->_currentStore = $store;
}
if ($type == 'group'
&& $this->_stores[$store]->getGroupId() == $this->_stores[$this->_currentStore]->getGroupId()) {
$this->_currentStore = $store;
}
if ($type == 'store') {
$this->_currentStore = $store;
}
}
return $this;
}
If session is not loggedin I unset the store cookie.