We have a legacy application (raw PHP) that is loaded from an Iframe in the Magento Frontend View. Now we need to detect from that legacy application if the user is logged in or not.
We had tried to store a value to $_SESSION from the Magento but while trying it, we realized that Magento uses different session name.
Do you have any alternative on how we can detect if the user is logged in or not from the legacy application that is loaded in an iframe?
Add a comment
|
1 Answer
You can check if user is logged in in the application with this piece of code:
Mage::getSingleton('customer/session')->isLoggedIn()
After you can get information about user. For example:
$customer=Mage::getSingleton('customer/session')->getCustomer();
echo "<pre>" print_r($customer);
and for example set $_SESSION['username']=$customer->getName();
-
As I said, Magento uses different session name (i.e frontend) and might have different session settings (i.e session_path).– NerCommented Oct 30, 2017 at 11:43
-
ah ok so use : Don't use $_SESSSiON var. Add something to the session like this: Mage::getSingleton('core/session')->setData('key_here', 'value_here'); To read it from the session do this: Mage::getSingleton('core/session')->getData('key_here'); or if you want to retrieve the value and remove it from the session do this: Mage::getSingleton('core/session')->getData('key_here', true); Commented Oct 30, 2017 at 14:39