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

Rodia
  • 1,407
  • 8
  • 22
  • 29
Hello World
  • 2,673
  • 7
  • 28
  • 60

1 Answers1

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

Community
  • 1
  • 1
maesbn
  • 207
  • 3
  • 6