How to set the timeout for a particular Session Variable.

Hi,

     I'm a  c# developer.I was dealing with a project based on session.Suddenly I had doubt of setting the timeout for a particular session variable

ie,Suppose I Have,

session["A"],session["B"],session["C"],session["D"]  etc as the sessions used in my project.

My Concern is,

Can i Individually set the timeout for session["A"],session["B"], etc.

I tried

using, sesson.timeout (); it's for the entire page.

setting the timeout in web.config is also for the entire project.

Help me please.

 

Thanks In Advance.

 




Answer this question

How to set the timeout for a particular Session Variable.

  • s potluri

    Is this in an ASP.NET application
    If you want a certain variable to expire after some time, why don't you use the Cache then, instead of the Session
    The problem is offcourse, that Cache doesn't have the same scope as Session. Cache is application specific, whereas Session is user-specific.

    However, I do not see why you want to 'expire a session variable' :


  • Kaarthik Sivashanmugam

    Yes, Off course i Can use form authentication

    and Using output cache directive would also solve my issue.

    but, still my concern is with the session.

    If you got any Idea Please Share it with me.

    Thank You.



  • Rob DeLine

    Why don't you use forms authentication .NET has some built-in login mechanisms. One of them is forms authentication.
    http://www.google.be/search hl=nl&q=asp.net+forms+authentication&btnG=Google+zoeken&meta=


  • Hugo Pozo

    Thank you Frederik,

    Ya,I'm Sorry,

    This is an ASP.NET application.And I'm using sessions for login authentication.

    Where in default Timeout for a session is 20 Min.And, i Just wanna reduce this into 10 Min .

    Hope u got me

    Thank You..



  • How to set the timeout for a particular Session Variable.