TimSo
TimSo

Reputation: 15

Make Session expire

I am using authentication mode=forms in web.config file. Because it is a secure application so I want to expire my session in 5 minutes. Right now I am doing it in programming in codebehind.

Is there any other easy way to do it?

Upvotes: 1

Views: 845

Answers (4)

The Muffin Man
The Muffin Man

Reputation: 20004

Is this what you're looking for?

<system.web>
    <authentication mode="Forms">
          <forms timeout="5"/>
    </authentication>
</system.web>

Upvotes: 0

Amit
Amit

Reputation: 22086

You should do it in Web.config file. This will expire Session

<configuration>
  <system.web>
    <sessionState 
      mode="InProc"
      cookieless="true"
      timeout="5" />
  </system.web>
</configuration>

Other option is, This will expire cookie

<authentication mode="Forms">
   <forms name=".ASPXAUTH" loginUrl="Login.aspx" protection="All" timeout="5" path="/" slidingExpiration="true">
   </forms>
</authentication>

Upvotes: 4

Vano Maisuradze
Vano Maisuradze

Reputation: 5909

You can do it from c#

HttpContext.Current.Session.Timeout = 5;

Upvotes: 3

Tomas Voracek
Tomas Voracek

Reputation: 5914

See http://msdn.microsoft.com/en-us/library/1d3t3c61.aspx, there is timeout parameter.

Upvotes: 0

Related Questions