website logins in xampp

Problems with the Windows version of XAMPP, questions, comments, and anything related.

website logins in xampp

Postby ibaker » 24. August 2016 03:29

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
ibaker
 
Posts: 5
Joined: 12. July 2016 01:58
XAMPP version: xampp-win32-7.0.8-0-VC14
Operating System: Windows 10 Pro

Re: website logins in xampp

Postby gsmith » 24. August 2016 06:43

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

127.0.0.1 forum1
127.0.0.1 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.

http://forum1
http://forum2

Now you have them separated them by domain and they cannot overwrite each other.
Last edited by gsmith on 24. August 2016 07:08, edited 2 times in total.
gsmith
 
Posts: 194
Joined: 29. November 2013 18:04
Location: San Diego
XAMPP version: 0.0.0
Operating System: Win XP to 2012R2/VS 6,9,11,14

Re: website logins in xampp

Postby ibaker » 24. August 2016 06:57

Thanks mate, however they both have their own domain:
http://localhost/Xenforo/
http://localhost/Xenforo_test/

And the url in both sites are set differently
Image
ibaker
 
Posts: 5
Joined: 12. July 2016 01:58
XAMPP version: xampp-win32-7.0.8-0-VC14
Operating System: Windows 10 Pro

Re: website logins in xampp

Postby gsmith » 24. August 2016 07:11

No they do not :)

http://domain/path/filename.
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.

Image
Last edited by gsmith on 24. August 2016 07:28, edited 3 times in total.
gsmith
 
Posts: 194
Joined: 29. November 2013 18:04
Location: San Diego
XAMPP version: 0.0.0
Operating System: Win XP to 2012R2/VS 6,9,11,14

Re: website logins in xampp

Postby ibaker » 24. August 2016 07:19

Oops, sorry of course they are the same domain, my mistake
ibaker
 
Posts: 5
Joined: 12. July 2016 01:58
XAMPP version: xampp-win32-7.0.8-0-VC14
Operating System: Windows 10 Pro


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 48 guests