Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access Magento customer's session from outside Magento? [duplicate]

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?

like image 548
Vish Avatar asked Apr 02 '12 18:04

Vish


1 Answers

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

like image 53
B00MER Avatar answered Nov 20 '22 19:11

B00MER