I want to redirect to login.php when my session expired , i test with two pages , i logout in the first and the second will detect the expired session and also this page disconnected . i do this :
in my index.php i have :
<script type="text/javascript">
$(document).ready(function(){
setInterval(function() {
$.post( "sessioncheck.php", function( data ) {
if(data == "-1")
{
alert("Your session has been expired!");
document.location = "login.php";
}
});
}, 3000);
});
</script>
and in sessioncheck.php i have :
session_start();
if(empty($_SESSION))
{
//expired
echo "-1";
}
else
{
//not expired
echo "1";
}
and in logout.php :
chdir("../../..");
include_once("config/config.php");
$_SESSION = array();
header("location:".__BACKURL."/login.php");
it's not working and i don't know were is the problem.