0

Guys I have a session called $_SESSION['id_session'] that contain the user ID now if i made this session in two different websites on my localhost it will share this session with both websites. Is that happening in online websites too? Here is the code that check if the used it logged in and his id is in a session

if(isset($_SESSION['id_session'])){
    header("Location: home.php");
}
  • Can you please explain how you're creating the *2 different websites*? Because, No. This is not normal behavior. – Ohgodwhy Dec 22 '15 at 23:36
  • Did you create two websites on localhost or just two different PHP files? – lwb Dec 22 '15 at 23:37
  • I have 2 different offline websites but both of them reserve the logged in used ID in $_SESSION['id_session'] and when i loggedin in on of the two sites it log me in in the other one too because both have the same sessions name which is $_SESSION['id_session'] – Ahmed Essam Dec 22 '15 at 23:40
  • sessions don't work on cross-domains. unless maybe they're on the same server and even then, you might have a hard time for them to both speak to each other. – Funk Forty Niner Dec 22 '15 at 23:40
  • you mean that this happens to me because im on a local host? it was two totally different websites but im using xampp so I opened one session and it worked for both websites – Ahmed Essam Dec 22 '15 at 23:44
  • @AhmedEssam How did you access the local websites? http://localhost/website1... and http://localhost/website2... ? – lwb Dec 22 '15 at 23:49
  • exactly yes thats what im doing – Ahmed Essam Dec 23 '15 at 00:00

0 Answers0