How to access Magento user's session from outside Magento?
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
Related videos on Youtube
Devplex
Web Developer and Systems Administrator at a Web Development company in The Netherlands.
Updated on April 17, 2022Comments
-
Devplex about 2 years
Im trying to access the Magento customer session in another part of my website.
domain.com/shop/ <- Magento domain.com/test.php
The shop itself works like a charm, however im trying to determine within test.php if a customer is logged in, so I can display his name with a link to his cart.
Contents of test.php so far:
<?php require_once dirname(__FILE__).'/shop/app/Mage.php'; umask(0); Mage::app('default'); Mage::getSingleton('core/session', array('name' => 'frontend')); var_dump(Mage::getSingleton('customer/session')->isLoggedIn()); ?>
I keep getting bool(false) returned. I'm logged into Magento at domain.com/shop/ so ‘true’ is expected.
Am I forgetting something?
-
Shakti Singh over 13 yearsWhy this is not working with joomla I tested it in separate page where it is working but not working with joomla always returns bool(false)
-
Benubird almost 11 years@Positive because this MAGENTO question is about MAGENTO, not joomla.
-
Paul Allsopp almost 9 yearsYou may want to create your own session model class as part of a custom module. That way you can store on it whatever you need, then in the other part of your website, instantiate the mage::app object and pull your session model data. Send me a message if you want more info on this