views:

419

answers:

1

Hi I am using asp.net 2.0 and I want admin session variable timeout for 1 hour.

Is it possible? and How?

I am using windows authentication.

A: 

You can set the session timeout globally in web.config:

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

And you can programmatically override that setting in your code (e.g. for the admin's session only), by setting Session.Timeout, e.g:

// set the current session's timeout to 60 minutes
// if the current user is an admin
if (currentUserIsAdmin)
    Session.Timeout = 60;

Have a look at this MSDN page for details.

M4N
Martin, If i programmmatically change on above condition then, will it affect globally? Like if admin session is created then all the other session will have timeout 60 min! otherwise 30 min
Vikas
No, if you set the timeout programmatically, you do it only for one session (the current session).
M4N