I have Magento CE installed in one of my client's site which is multistore site.

Now I have following code in header file for checking whether a customer is logged in or not using session model and showing appropriate login/logout links as per condition.

                foreach($_storeArr as $store):
                    $storeBaseUrl = Mage::app()->getStore($store['id'])->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
                    $helper = Mage::helper('customer');
                    $custSession = Mage::getModel('customer/session'); ?>
                        <?php if ($custSession->isLoggedIn()): ?>
                            <a href="<?php echo $storeBaseUrl.'customer/account/logout'; ?>"><?php echo $this->__('Logout ').$store['name']; ?></a>
                        <?php else: ?>
                            <a href="<?php echo $storeBaseUrl.'customer/account/login'; ?>"><?php echo $this->__('Login ').$store['name']; ?></a>
                        <?php endif; ?>
<?php endforeach; ?>

But I want to show both store's login links such that if a customer is logged in any store it would show logout link only for that store.

Right now it shows logout link for both stores, even if a customer is logged in any store.

Can anyone guide on this ?

1 Answer 1


Go to

System->Configuration->Customers->Customer configuration->Account sharing option

Then change Share Customer Accounts to per website from global

  • Yes I saw it already from google-search, but is there no way the session check storewise can be done from code, i.e. by overriding the isLoggedIn method, how to achieve this by code, what should I do so that storeId is taken into acount while checking isLoggedIn, is my question I think.
    – Vicky Dev
    Aug 26, 2016 at 6:59
  • By default, Magento only supports limiting user accounts on a Global or per Website basis, not per Store. To try to answer your question, you can force the user to logout between stores/websites. Look in Admin > System > Configuration > General > Web > Session Validation Settings and set Use SID on Frontend to No. If the limitations have to be per Store, then you will need a module to introduce that.
    – NID
    Aug 26, 2016 at 7:26
  • Moreover account sharing setting also done as you suggested, but still same issue.
    – Vicky Dev
    Aug 26, 2016 at 12:36

Your Answer

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

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