Page 1 of 1

website logins in xampp

PostPosted: 24. August 2016 03:29
by ibaker
I have 2 versions of a website in xampp on localhost however I can't be logged in to both at the same time.

The situation
I have Xenforo forum software websites, one being a copy of my life site and one being a new install for development
Both are installed in htdocs under different folders in xampp on my local PC using localhost/site1 and localhost/site2
My admin login to both sites is the same
When I open 1 up and login all is ok
When I open the 2nd site up and log in whilst logged in to the first site, I get logged out of the first site

I had xampp installed on a previous PC and didn't have this issue for some reason

Any suggestions on what to do...thanks

Re: website logins in xampp

PostPosted: 24. August 2016 06:43
by gsmith
Well, I'm going to guess it is because of Cookies. Look at a cookies structure.

setcookie(cookie_name, cookie_value, cookie_expiration, path, domain, secure);

If both sites are on localhost, then there is no domain separation.
You probably cannot change the paths, most software sets cookies with the path of / so there is no path separation.
I looked over a demo and there was no way to change the cookie names so you cannot separate them like that.

So, both instances have the same domain, same path, same cookie names. Basically the second log in overwrites the cookies set by the first login.

Edited to add:
And even if you used same username and password on both, there is most likely a session cookie as well and like the others gets overwritten too. When you go back to the first the session will not match and it will kick you to the login.
End Edit:

All is not hopeless however.

Use your windows hosts file and add an entry for each .... say for example forum1 and forum2 forum1 forum2

Give each one a VirtualHost in Apache and use the ServerNames of forum1 and forum2. Set the DocumentRoots of each virtualhost to their respective locations for example c:/xampp/htdocs/forum1 & c:/xampp/htdocs/forum1
Give them the least needed permissions for it to run. Being that the docroots are under htdocs (assumption here) you probably do not have to worry about this as they will pick up the same permissions as c:/xampp/htdocs.


Now you have them separated them by domain and they cannot overwrite each other.

Re: website logins in xampp

PostPosted: 24. August 2016 06:57
by ibaker
Thanks mate, however they both have their own domain:

And the url in both sites are set differently

Re: website logins in xampp

PostPosted: 24. August 2016 07:11
by gsmith
No they do not :)

the domain for both is localhost.

I can view all cookies in my browser and I see they set one or two cookies. They are both session cookies, one of user, one for admin and they set the path at '/' (no surprise) as you can see in the image. I ogged in and out twice and the cookie names are the same. The sessions will not be the same when you go back to the first so .... well you know, you get kicked from the first because the second login overwrites the session cookie with it's session.


Re: website logins in xampp

PostPosted: 24. August 2016 07:19
by ibaker
Oops, sorry of course they are the same domain, my mistake