I have set multiple websites on my magento store.I used Marius extension to share cart on different sites.Now i am facing login issue that i have to login on every site individually.I want that after login to one site it will automatically logged me in on other two sites.All the three sites are in one magento Folder.Should i use cookie but i am not sure that either it's good idea or not ? Any alternative way to share session among sites

1 Answer 1


The similar question was asked many times before and it seems that it stil haven't complete solution. My answer will be based on already solved solutions published here:

If you want to have single account for all multi-stores you have to do the following:

1 Share customer accounts

You can configure this feature here: System -> Configuration -> Customer Configuration -> Share Customer Accounts.

2. Share sessions between Magento websites.

There are 3 possible store configurations:

  1. If your websites are located in one domain, but in different directories, e.g. "www.example.com/stores/store1" and "www.example.com/stores/store2" you can setup your "Cookie Path" to "/stores/" in System -> Configuration -> Web -> Session Cookie Management.

  2. If your websites are located in different sub-domains e.g. "store1.example.com" and "store2.example.com" you can setup "Cookie Domain" to ".example.com" in System -> Configuration -> Web -> Session Cookie Management.

  3. If you have different domains, in this case you can add session ID to the URL for another store. Use this construction "Mage::getModel('core/url')->addSessionParam()->getUrl('...')" to get the URL with session parameter.

After that your customers will be able to switch between multi-stores Magento websites without re-login. In other words, if customer will login in one Magento website, he will be able to see another multi-store Magento website using his first store account.

There is also a code based solution.

  • Overwrite magento/app/code/core/Mage/Customers/Model/Customer.php and change again the method getSharedWebsiteIds() to:
        public function getSharedWebsiteIds() { 
            $ids = $this->_getData('shared_website_ids'); 
            if ($ids === null) { 
                $ids = array(); 
                if ((bool)$this->getSharingConfig()->isWebsiteScope()) { 
                    $ids[] = $this->getWebsiteId(); 
                } else { 
                    foreach (Mage::app()->getWebsites() as $website) { 
                        $ids[] = $website->getId(); 
                $this->setData('shared_website_ids', $ids); 
            } return $ids; 

  • overwrite magento/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php


replace this

// potential custom logic for session id (ex. switching between hosts)


// potential custom logic for session id (ex. switching between hosts)
/* Amend to ensure shopping carts are shared between websites */
if (isset($_COOKIE['lastsid']))
            setcookie ('lastsid', '', time() - 3600);

        if (isset($_GET['SID']))
            session_decode(file_get_contents(Mage::getBaseDir('session') . '/sess_' . $_GET['SID']));
            setcookie('lastsid', $_GET['SID']);
            $_COOKIE['lastsid'] = $_GET['SID'];
        /* Amend end */
  • 1
    Link-based answers are not the best answers. Links can be broken and disappear over time. Please copy and attribute the portions that you feel are pertinent to answering this question.
    – philwinkle
    Feb 13, 2015 at 20:11
  • Duplicating of the content and plagiarism are not the best approaches to solve the well known issues. So I provideed the best answers on my opinion. Feb 13, 2015 at 20:51
  • It isn't plagiarism if the source is documented. Read this meta.stackexchange.com/a/8259
    – philwinkle
    Feb 13, 2015 at 20:56
  • Ok, I'll edit it Feb 13, 2015 at 20:57
  • I have implemented your code but user is not logged in on other sites.when i logged into one site its not share the session on other sites to automatically logged me in.I have changed the files you mentioned in answer. Feb 16, 2015 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.