5

I have following issue: I have a multistore installation where I have

  1. a main store (example.com)
  2. a second store for members only (sub.example.com), which has the login page as the start page on that store, and then has a more extensive product offering.

When a customer lands on example.com, we have a banner which informs (and link to redirect) the club members to use sub.example.com. However, when registered users of sub.example.com try to login on sub.example.com (after being redirected), they face the issue that they can't login and no error message is displayed.

My research leads me to believe that this is a cookie problem, stemming from the fact that the example.com cookie is set, and then causes problems when the user is redirected to sub.example.com

login works on all browsers after cookies and cache is cleaned, except for IE and safari. Users still can't login.

Session cookie management settings are:

  • Cookie Lifetime: 31536000
  • Cookie path: /
  • Cookie domain: (empty)
  • Use HTTP only: No
  • Cookie restriction Mode: No

I tried setting the cookie domain ".example.com", that didn't work either

Does anyone know how to solve that general cookie problem or what can be done so that IE and Safari users can login?

  • 1
    If you haven't already set it, ensure that use SID in URL is enabled, and ensure all your domains share the same session store on the server. – Ben Lessani - Sonassi Nov 30 '14 at 16:49
  • No, don't use SID in URL in webshops (in general) unless you know specifically what you're doing (the general suggestion to use it is wrong). – hakre Jul 26 '15 at 12:52
4

You write in your question:

they face the issue that they can't login and no error message is displayed

This is a good indicator that you have a cookie issue. This error pattern is just that the login was successful for Magento (username and password did match) but there is no session to keep the successful login. Hence the login page is displayed again with no error message.

My research leads me to believe that this is a cookie problem, stemming from the fact that the example.com cookie is set, and then causes problems when the user is redirected to sub.example.com

You're pretty close, here is what happens.

  • You have not specified a cookie-domain for both sites.
  • Not specifying a cookie-domain means, the browser when it receives a cookie will file it under the domain of the request.
  • The login will then set the session ID to example.com. In that session the user is logged in.
  • After redirect a new session ID will be set to sub.example.com. In that new session the user is not logged in.
  • If the browser requests a page under sub.example.com then, it needs to decide which of the two same-named cookies for the session is to be taken: The one for example.com or the one for sub.example.com? And if both in which order? Answer: You can't say as browsers vary here.
  • And not only the browser, also the server needs to decide here. So what happens here? Answer: For PHP, it can't handle two cookie values with the same name. It only takes the first one. And which one that is, you can't say (see browsers).
  • So this is already flawed. No wonder it won't work until you start fresh and remove existing cookies under both domains.

This is what you experienced and hopefully the listing sheds some light.

So how to handle this in your case?

My suggestion would be to configure the cookie domains as "example.com" for all the two sites in your case. That means that both sites will share their session which I assume is what you're looking for.

Not setting the cookie-domain in the first place was causing you the trouble then as this resulted in two different cookie domains, but you want to share the session cookie, so you want one session cookie and not two.

Also: Set the cookie to HTTP only so it can't be spoofed in a browser-script.

Changes in your configuration:

  • Cookie domain: example.com (was: (empty))
  • Use HTTP only: Yes (was: No)
0

I am pretty sure what you are describing is due to a lack of a formkey on the login page and unrelated to being redirected.

In your preferred editor open up

/app/design/frontend/default/template-name/template/persistent/customer/form/login.phtml

Inside the "login form" form, after the

<ul class="form-list">

Check to see if you have a line like the following

<input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />

If it is missing, add it and test

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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