How to access Magento user's session from outside Magento?

元气小坏坏 提交于 2019-11-27 04:33:50

I would recommend checking the path of the cookie that Magento sets. Most likely, it is set to /shop, so the cookie will not be accessible to your file above it.

You can modify the path that Magento uses to set its cookie in the control panel under System -> Configuration -> Web (under the General heading) -> Session cookie management

vknyvz

it is under confuguration-> web on Magento ver. 1.10.1.1

The same issue was driving me mad. I worked through the following until the last item solved it:

  • Has the correct Mage store ID (current store) been set?
  • Are you using the same session path as Magento?
  • Are you using the same (sub)domain for cookie purposes?
  • Are you using HTTP or HTTPS both inside and outside Magento?

If you've checked all the above, make sure you initialize a core "frontend" session on its own first like this:

// Initialise the core "frontend" session
Mage::getModel('core/session', array('name' => 'frontend'));

Then you can access the customer/session like this:

$customer = Mage::getSingleton("customer/session", array('name' => 'frontend'))->getCustomer();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!