The Mask The Mask - 11 months ago 91
ASP.NET (C#) Question

set the timeout for a specific session

How I can set the timeout for a session specific in ASP.NET? it is possible?
I have two or more sesions in my web application, I need set:

Session["foo"] //expire in 14minutes
Session["baa"] //expire in 30minutes

I'm wanting solve this case,if possible not using cookies.

Thanks in advance!

Tim Tim

You can configure the timeout for a session in the Web.config file:

    <sessionstate mode="inproc"
                  timeout="14" />

This is the default mode (InProc) for ASP.NET. As rockinthesixtring said in his comment, you can't configure the timeout for individual objects in the session, just the session as a whole.

ASP.NET Session State Overview