I have a custom logout page. When user clicks logout this page is reached (and logout status is saved in database). There is no login mechanism. If a user tries in a new window he is allowed to view the page and logout status is changed as logged In.
Once logged out, when user is clicking back button (from logout page), it should not allow user to view previous page.
Similarly: When user access a page, the time is stored. When he is idle for 20 min and attempt an operation he will be redirected to session timed out. He should not be able to view previous page on back button click.
Currently in each page I am checking the database status and redirecting to logged out page again if status is logged out. But it causes the page to load first and then do validation in javascript and then redirect. Is there a better way to handle this?
Note: I am posting it as a new question based on the comment in Clear browser history
$.ajax(
{
type: "POST",
url: "LogOut.aspx/GetActiveIndicatorStatus",
data: '{"empID": "' + empID + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: navigateBasedOnStatus
}
);
//Helper Function
function navigateBasedOnStatus(result) {
if (result.hasOwnProperty("d")) {
result = result.d
}
//alert($.trim(result));
if ($.trim(result) == "LoggedOUT") {
window.location.href("LogOut.aspx");
}
else
{
contentHolderDiv.css("display", "block");
}
}
REFERENCE: