0

I have created a website, I have to login to view this site, now I have copied all files into a new directory and created a separate database for that.

The problem is whenever I am logging in one site the other one is also logging in, and also for log out. Can anyone tell me why this is happening? My server is running on localhost (XAMPP).

I followed this tutorial to create login page: https://www.tutorialspoint.com/php/php_mysql_login.htm

7
  • This question is far too vague - please give some examples of the code you are having problems with. Commented Mar 20, 2017 at 17:12
  • you're not really thinking of going live with that, are you? Commented Mar 20, 2017 at 17:13
  • "Can anyone tell me why this is happening" - No idea; I'm not "there". Commented Mar 20, 2017 at 17:14
  • "Thanks" - For what? we haven't even done anything yet. You haven't told us what's not working? Commented Mar 20, 2017 at 17:15
  • @Fred-ii- I have linked a url in the question and there is the code i am using in. Commented Mar 20, 2017 at 17:37

1 Answer 1

1

When us store data in the session like you do at $_SESSION['login_user'], this session stored data is for your domain. When you copy the application in an other directory, it still runs under the same domain thus it will access the same session data. You can fix this by making the session data key unique to its directory ex. $_SESSION[$domain.'_login_user'] with $domain being some application specific variable.

Also take a look into session hijacking when using sessions, you are definitely not using them safely: PHP Session Fixation / Hijacking

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I understood why this is happening. Problem Fixed.!!

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.