Different Session Timeout per each user

Using Session.Timeout in code behind will set the timeout on a per user basis. Setting SessionState Timeout in Web.Config is for all users.

So for each user we can Set the Session timeout in Session_Start method like below

//Gets the usertimeout preference from database
int usertimeout=GetUserTimeOut(HttpContext.Current.Session["UserId"]);
//Change the session timeout for the current session
HttpContext.Current.Session.Timeout= usertimeout

Gopikrishna

    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment