Echo Magento Session ID

If you’ve set up a Magento installation with multiple domains, it’s quite likely that you’d like to carry sessions over to the different domains. This functionality is built into Magento but isn’t documented very well.

The following snippet of code will obtain the encrypted session ID used by the current session. You can then use this session ID to carry over the session to the other domains.

<?php $sessionId = Mage::getSingleton("core/session")->getEncryptedSessionId(); ?>

A simple example of a link:

<a href="<?php echo Mage::getSingleton("core/session")->getEncryptedSessionId(); ?>">Domain 2</a>

Posted by Nath

Nath is our Lead Magento Developer. He is a highly regarded Magento developer with vast knowledge and experience.