first page :
Code: Select all
login.php :
session_start();
if (isset($_SESSION) && sizeof($_SESSION)>0)
{
session_unset(); // session_destroy
}
function Identify($login,$mdp)
{
global $sess_id, $link, $PHPSESSID, $_SESSION, $HTTP_SESSION_VARS;
//... DATABASE request ... it's matching then :
$sess_id=$var->id;
session_register("sess_id");
/*
note :
i've ttried this too :
$HTTP_SESSION_VARSї"sess_id"]=$sess_id;
or $_SESSIONї"sess_id"]=$sess_id;
*/
header("Location: index.php?PHPSESSID=".$PHPSESSID);
exit();
}
// When the form is posted :
if (isset($login) && Trim($login)!="" && isset($mdp) && Trim($mdp)!="")
{
Identify($login, $mdp);
}Second page :
Code: Select all
index.php
session_start();
if (!isset($_SESSIONї'sess_id']))
{
header("location: login.php");
}
include "page1.php";
include "page2.php";
....So each time i made a form or url link, i pass the PHPSESSID value and the session is recognized and go on working.
But sometimes it dont ! Exemple, if i do some refresh on a page that has been recognized, it work and in a while (never the same time ) it fails.
I dont know why ?? it's like the session was destroyed in index.php sometimes and sometimes not ?
Anyone could explain me why ?? or is it my structure that is bad ? Moreover as this always work on my local server i though it was fine .....
Thx for help because i'm stuck on this for a long time ....