How to access Magento customer's session from

2020-01-31 03:25发布

First up, my question is very similar to questions asked in Stackoverflow (and the web) such as: How to access Magento user's session from outside Magento?

What I need is, if a customer is logged into a Magento site, I want him to be logged on to a forum too. But try as I might, I'm unable to get isLoggedIn() to be true. Any suggestions on what I might be missing? Here's the minimal code chunk that should get me logged-in information:

require_once '/abs/path/to/Mage.php';
umask(0);
Mage::app('default');
Mage::getSingleton('core/session', array('name' => 'frontend'));
$session = Mage::getSingleton('customer/session');           
Zend_Debug::dump($session->isLoggedIn());

I checked the following:

  • cookie path is set to '/'
  • I dumped the $session variable and didn't get wiser
  • As described here, I tried setting "Use Session ID in frontend", but it appears my Magento doesn't have that option (We use magento 1.3.2.4).
  • I'm checking the variable of course by logging in and out as a customer
  • Am including mage.php

Any help on what I might be missing?

1条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-01-31 04:21

You will need to enter in .domain.com in Magentos admin->system->configuration->web->cookie domain. Like erickthered mentioned, you will need to make the cookie available to your other subdomains in order for it to be read. This is the same with all web applications.

Reference: http://www.magentocommerce.com/wiki/modules_reference/english/mage_adminhtml/system_config/edit/web#session_cookie_management_field_descriptions

查看更多
登录 后发表回答