Last post Sep 09, 2014 08:47 AM by Eswaran_MCA
Sep 09, 2014 03:31 AM|dora407|LINK
I am using MVC4, in my web application i am setting Status flag to true in database for logged in user's. when user's Log out, i am setting status to false. I am saving userId in Session , based on that userId i am doing this.
but when session Expired , my userId id gone. now how can we do this ?
I need to set status flag false, when Session Expires and browser closes.
How can we do this ?
Sep 09, 2014 04:55 AM|Eswaran_MCA|LINK
Browser does not know, the session expired. We can acheive this by two ways.
1/ We have a function in Global.aspx called "Session_End". if user session gets expired then user make any request, then this "Session_End" routine will execute automatically. Then whatever you want do that inside the function.
2/ Create a base class "WebPageBase". In that class create a constructor and check if the session expired or null. Inherite this class to all your webpages. all the page_load function call the base class constructor. if it session gets expired then set false
to that variable in WebPageBase class constructor.
Sep 09, 2014 08:07 AM|dora407|LINK
Thank you Eswaran_MCA,
your suggestion works for me.
Sep 09, 2014 08:47 AM|Eswaran_MCA|LINK
If it works pls mark this as answer