Hi I am developer in .NET but I need to access session object in client side and redirect the page to login. i am using the following code snippet but I am unable to achieve the target.
function CheckSession() {
var session = '<%=Session["username"] != null%>';
//session = '<%=Session["username"]%>';
alert(session);
if (session == false) {
alert("Your Session has expired");
window.location = "login.aspx";
}
else {
alert(session);
}
}
I am getting
'<%=Session["username"] != null%>'
this condition as always true whether the session has expired or not.
Is there any way to check that the session has expired or not.
Any help will be appreciated.