Jump to content

Change cookiename (2 shops)


Recommended Posts

Hi all!

I have 2 shops on different domains, 1 original and 1 copy.
The problem is that admin get gets screw uped cause both shops have the same cookiename.
I guess thats the problem anyway.

As it is now I have to admin one shop in Chrome and one in IE.

Is it possible to change the cookienamne like cookie_shopename1_com and cookie_shopname2_com?

Thanks in advance!

/Thomas

Link to comment
Share on other sites

you shouldn't have any problems, the database are different, the domains are different, even with same cookie names there is no issue.

if you get an error please let me know how I can replicate it

Link to comment
Share on other sites

  • 1 year later...

Sorry to dig up an old thread but I have a similar problem.

 

I had 1 main website (www.mysite.com) running 1.4.9.0.

 

I needed to duplicate the site and run it independently from a sub domain (www.sub.mysite.com)

 

I changed all of the variables in settings.inc.php, yes i changed the define COOKIE_KEY & COOKIE_IV in the duplicate.

 

I have both sites running fine almost 90% of the time but here is my problem:

 

If a customer visits my main site (www.mysite.com) it places a cookie on the computer with a unique "Cookie Name", then if the same customer visits my sub domain (www.sub.mysite.com) and tries to log in, they can't?? I have looked at the cookies the sites place on my computer and they both have the same "Cookie Name" this is the only thing I think is conflicting. When they try to log in it just clears the login boxes and refreshes the page.

 

If I remove the cookie which (www.mysite.com) placed on my computer and try to login (www.sub.mysite.com) again it works fine?

 

Like I said I have different settings in settings.inc.php but even if I change these again I always get 2 cookies with the same name??

 

How do I change the generated cookie name of (www.sub.mysite.com)?? I have looked in "classes/cookie.php" and found "$this->_name = md5($name);" but i assume this is using the COOKIE_KEY from setting.inc.php for the md5??

 

I have changed COOKIE_KEY setting several times but the cookie name never changes??

Edited by evolution.x (see edit history)
Link to comment
Share on other sites

if "yes i changed the define COOKIE_KEY & COOKIE_IV in the duplicate"

then the login won't work anymore because the encryption is different. Leave them alone and it should work fine or at least as far as I can see now

Link to comment
Share on other sites

if "yes i changed the define COOKIE_KEY & COOKIE_IV in the duplicate"

then the login won't work anymore because the encryption is different. Leave them alone and it should work fine or at least as far as I can see now

 

I changed the COOKIE_KEY & COOKIE_IV yes but i also reencryped all of the passwords on md5.fr with the new COOKIE_KEY

Edited by evolution.x (see edit history)
Link to comment
Share on other sites

check the built in support for sharing cookies between domain and subdomain. I don't use it but PS does support the sharing of cookies this way.

 

back office-->tools-->subdomains

 

It's not that i want to share the cookie i need them to be 2 independent websites, it is basically a retail and trade site.

Link to comment
Share on other sites

I have solved the problem, i compared the cookie.php from 3 PS versions, 1.3.2.3, 1.4.9.0 & 1.5.3.1.

 

I noticed that on around line 66, this code is different:

 

In 1.4.9.0 is it:

 

 $this->_name = md5($name);

 

In 1.3.2.3 it is:

 

 $this->_name = md5($name._COOKIE_KEY_);

 

And in 1.5.3.1 it is:

 

 $this->_name = md5(_PS_VERSION_.$name);

 

The 2 sites i am running are 1.4.9.0 and if you look at the code it only encrypts with $name, if both shops are called the same thing this will give the same cookie name, so i added this code to 1.4.9.0:

 

 $this->_name = md5($name._COOKIE_KEY_);

 

Which now encrypts the shop name against the COOKIE_KEY, and the cookie keys are different in each site resulting in different cookie names.

 

Not sure why PS decided to remove this from 1.4.9.0??

Edited by evolution.x (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...

Just want to say thank you as well:

 

Had this problem:

 

2 different shops with different database/files on sub.domain.org and www.domain.org  (same physical server)

 

After logging in at sub.domain.org I could see account details at www.domain.org of a different customer. Actually the data from the customer with the same id but of the wrong shop... not good at all.

 

 

Shop was 1.5.4.1

 

This solved the problem.

Don't know if it happened because of copy of shops, but this helps: $this->_name = md5($name._COOKIE_KEY_);

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...