Magento Session在外部页面(同一域)中不起作用 [英] Magento Session not working in external page (same domain)

查看:82
本文介绍了Magento Session在外部页面(同一域)中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

外部页面(相同域)中的Magento会话运行不正常,我在这里检查了所有其他主题,但是任何可行的解决方案.

Magento Session in external page (same domain) is not working well, I've checked all the other topics here but any solution it is working.

require_once ( "../app/Mage.php" );
umask(0);
Mage::app("default");

Mage::getSingleton("core/session", array("name" => "frontend"));
$session = Mage::getSingleton("customer/session"); 


if($session->isLoggedIn()){
    //do it
} else {
    //  Transfer them to a login page
    header("Location: http://www.mydomain.com/customer/account/login/");
} 

我无法使用它,我已经检查了所有建议,但无济于事.

I can not get this to work, I have checked all recommendations everywhere and nothing work.

推荐答案

我认为您的问题是您已经启动了会话,因此尝试启动magento会话并从中获取数据的尝试失败. 如果查看Mage_Core_Model_Session_Abstract_Varien,它所做的第一件事就是查看$ _SESSION变量是否已设置,如果已设置则返回.您可以在此处设置调试器断点,然后验证是否不确定. 您可以关闭其他会话并启动magento会话以获取数据,也可以让两者共享同一会话

I think your issue is that you already have a session started, so your attempts to start a magento session and get data from it are failing. If you look inside Mage_Core_Model_Session_Abstract_Varien, the first thing it does is look to see if the $_SESSION variable is already set and return if it is. You could set your debugger breakpoint there and verify if you aren't sure. You could close the other session and start the magento session to get your data, or you could get both to share the same session

这篇关于Magento Session在外部页面(同一域)中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆