Check every time if Session has expired and if yes then redirect to home page by using JavaScript such as facebook do if I press ctrl+shift+del then it shows login window. I am using .aspx web pages and using WCF services
I do not know if this is the best solution, but here's a solution that will test every 500 milliseconds if the user session has expired
Checker permanently a session variable with "setInterval" function every 500 milliseconds :
function CheckSession() {
var session = '<%=Session["username"] != null%>';
//session = '<%=Session["username"]%>';
if (session == false) {
alert("Your Session has expired");
window.location = "login.aspx";
}
}
setInterval(CheckSession(),500);
See here : http://www.daniweb.com/web-development/javascript-dhtml-ajax/threads/362898/check-for-session-timeout-in-javascript-and-redirect-to-login-page#
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With