I've a problem. I've created a web app where the person logs in and many $_SESSION[...] are set. The point I found weird is that if I log in in the folder http://demo.site.com/ and I log in in http://webapp2.site.com I get the session data mixed up in the two web apps...
This is the code in the checkentry.php (which check the person is logged in before sending it to the main page:
<?php
session_start();
if(isset($_SESSION['autenticated']) && $_SESSION['autenticated'] == TRUE && isset($_COOKIE["login"]) && $_COOKIE["login"] == $_SESSION['ssnid']){
if (!isset($_SERVER['HTTPS']) ){
//header('Location: https://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"].'');
}
return true;
}else{
require_once("config.php");
$logout_connect = mysql_connect($db_host, $db_user, $db_pass);
if (!$logout_connect){
die('Impossibile connettersi: ' . mysql_error());
}else{
mysql_select_db($db_name, $logout_connect);
mysql_query("DELETE FROM sessions WHERE ssnid = '".$_SESSION['ssnid']."' AND userid = '".$_SESSION['userid']."'");
setcookie("login", "", time()-3600);
}
session_destroy();
header("location: login.php?requested");
}
?>
So the problem is the fact that If I'm logged in in both web app (and in the same domain has many web-apps in different folders) I get the $_Session data mixed.
[EDIT] When I log out from app1.site.com I get logged out from app2.site.com too...
What did I do wrong and how to fix it?
Tku