2

I have a magento shop and for testing purposes I use a subdomain

www.example.com/shop -> shop

test.example.com/ ->subdomain

I am trying to access the Magento session from the subdomain with the following code (test.php)

require_once 'shop/app/Mage.php';
umask(0);
Mage::app();

Mage::getSingleton('core/session', array('name' => 'frontend'));
var_dump(Mage::getSingleton('customer/session')->isLoggedIn());

Like in this question and in this question and following the Magento Wiki I set the Cookie Path to

/

and the Cookie Domain to

.example.com

Still the test.example.com/test.php returns false. Also this logs me out somehow. So when refreshing the shop in another tab, the user is logged out. When testing the same file from www.example.com/test.php everything works fine.

What else could be the problem in my case? Any suggestions?

Community
  • 1
  • 1
bennos
  • 313
  • 4
  • 17

1 Answers1

1

After I created a login function on my test.example.com subdomain I saw, that I can login to the shop, creating a Cookie with the domain .example.com. The thing is, that the actual shop at example.com does not recognise this cookie and shows the user as not logged in.

In my case, where I have only my testing environment on test.example.com and don't need to switch to the shop in a live environment this is no problem. For anyone having the same problem: I guess it is somehow connected with the session-cookie. This is only a guess. Maybe try some of the suggested answers here

Community
  • 1
  • 1
bennos
  • 313
  • 4
  • 17