In Block class:
In template(phtml):
public function _toHtml(){
Mage::getSingleton('customer/session')->setBeforeAuthUrl($this->getRequest()->getRequestUri());
if (!Mage::getSingleton('customer/session')->isLoggedIn()){
header("Status: 301");
header('Location: '.$this->getUrl('customer/account/login')) ; // send to the login page
exit;
}
}
In template(phtml):
Mage::getSingleton('customer/session')->setBeforeAuthUrl($this->getRequest()->getRequestUri());
if (!Mage::getSingleton('customer/session')->isLoggedIn()){
header("Status: 301");
header('Location: '.$this->getUrl('customer/account/login')) ; // send to the login page
exit;
本文介绍了一个Magento应用程序中的功能,该功能确保未认证用户被重定向到登录页面。通过使用Magento的Customer Session模型设置登录前的URL,并检查用户是否已登录来实现。
899

被折叠的 条评论
为什么被折叠?



