Reputation: 9043
Is it possible to set the timeout of a session variable to say one hour programatically.
How would I go about in doing this?
The reason I am asking is because of storing the contents of an arraylist into a session variable and these contents needs to be available way beyond the current timeout of the session variable.
Upvotes: 1
Views: 653
Reputation: 64923
No, because the timeout works for the entire session.
But you can set an artificial expiration time for the session item and increase the session max idle time/timeout. Thus you can store an object like this:
public class SessionValue
{
public object Value { get;set; }
public DateTimeOffset ExpiresOn { get;set; }
}
And whenever you get the whole session item, you can check if it's still valid or it has expired.
Upvotes: 2