We can achieve using the php and ajax.The following ajax call execute in every 10 seconds to check the status of session.If it expired the user redirected to seesionout page.
Ajax call in every 10 seconds
var check_current_session;
function CheckForCurrentSession() {
var strSession=”check_current_session=true”;
jQuery.ajax({
type: “GET”,
url: “check_current_session.php”,
data: strSession,
cache: false,
success: function(result){
if(result== “Y”) {
alert(‘Your session Already expired!’);
window.loaction(‘https://smarttips.in/sessionout.php’);
}
}
});
}
check_current_session = setInterval(CheckForCurrentSession, 10000);
PHP Code
session_start();
$sessionId = $_SESSION[“uid”];
if($sessionId == ”)
{
//session already expired
echo “Y”;
} else {
//session not expired yet
echo “N”;
}
You can also Download free script here