I am using asp.net, vb.net, and jquery. I need to see if my session exists or not in jQuery. I know that I cannot work with sessions in jQuery due to JavaScript being client side while sessions are server side. So, I thought a work-around could be storing the session info in a label.
Here is what I am trying that is not quite working:
So on Page_Load, I set the textbox to session (which equals "True" when the session exists): LblSession.Text = Session("MySession")
Also on Page_Load, if the session expires (set to 15 mins), then I want the label to update the session to be null / false.
If Not Session("MySession") Then LblSession.Text = Session("MySession")
However when my session ends, this label doesn't update to if the session exists or not.
On my jQuery, I get the value of the session (if it exists, it is True, otherwise, it is false or null): var mySession = $("#LblSession").text();
//Check to see if the session is true
if (mySession == "True") {
'do something if session exists'
} else {
'do something if session does not exist'
}
This is my ultimate goal, to be able to see if the session exists or if it expired from my jQuery.