Is there a sanctioned method for adding TTL to ASP.NET InProc Session State entries?
Example:
Session("First", 60) = "John"
Session("Adams", 500) = "Adams"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Out of the box, no there isn’t. Individual Session State Key-Value-Pairs do not have any built-in method for adding a TTL or TTE.
Regarding the “global” InProc session state-timeout, it is controlled by a session state wide value configured in your
web.configfile (thetimeoutvalue in the/system.web/sessionStatesettings).Additionally, whilst it may look like an attractive proposition to create your own session state provider, you couldn’t use the
Sessionproperty exposed by the page or controller code as this returns aHttpSessionStateobject. None of the methods, properties or indexers support having an extra parameter to specify individual session value timeouts.You may consider doing the following:
Maintain an active session for each user:
Session(“PersistMe”) = true
Grab SessionID, and use it to store values in the ASP.NET Cache where you may utilize a TTL value.