Solved

Asp.Net: how-to modify timeout for users

Posted on 2004-08-13
10
252 Views
Last Modified: 2010-04-07
Hello experts,
the timeout value in my Asp.Net (VB.Net) application is generally set in web.config to 10 minutes.
Now I want to modify this value for several users to 30 minutes.
How can I ensure that a new set value is used in all web pages for these users only.

If anyone knows a solution please supply appropriate [snippet] information.

   Thank you very much!

     HStrix
 
0
Comment
Question by:HStrix
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
10 Comments
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11793037
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11793359
Sub Application_Start(Sender As Object, E As EventArgs)
  ' Application startup code goes here
End Sub

Sub Session_Start(Sender As Object, E As EventArgs)
  Response.Write("Session is Starting...<br>")
  Session.Timeout = 1
End Sub
0
 
LVL 8

Expert Comment

by:daffodils
ID: 11795038
AerosSaga is right..

You can use "Session_Start" in Global.asax to set the Session Timeout.
The Context.User.Identity.Name or Context.User.IsInRole properties can be used to conditionaly set the Session.Timeout property.

protected void Session_Start(Object sender, EventArgs e)
{
       if(Context.User.Identity.Name = "HStrix")
       {
      Session.Timeout = 30;
       }

       if(this.Context.User.IsInRole = "Admin")
       {
      Session.Timeout = 30;
       }
}
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:daffodils
ID: 11795153
Wait.. those functions have syntax errors. I am sorry... I can't believe I missed that !!!!!

if(Context.User.Identity.Name == "HStrix")
{
   Session.Timeout = 30;
}
if(this.Context.User.IsInRole("Admin"))
{
   Session.Timeout = 30;
}
0
 

Author Comment

by:HStrix
ID: 11798969
Thank you for your comments.

Because ,
   I'm using InProc session management.
   I don't use Windows authentication.
and
   My application has its own user management.
   I'm using a session variable Session("UserID") to identify a user.

Can I use  Session("UserID") in Session_Start too?

0
 

Author Comment

by:HStrix
ID: 11799107
I forgot to mention that I also don't use cookies.
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11799771
when does userID get assigned?
0
 

Author Comment

by:HStrix
ID: 11799828
When the application starts,
a login screen appears asking for an id with a password.
This will be compared with an information read from a  database.
If it was successful, the accepted userid is moved into the session variable.
This session variable is used through the entire life of the session,
i.e. until a logoff or a timeout.
0
 
LVL 17

Accepted Solution

by:
AerosSaga earned 500 total points
ID: 11800236
yes that will be fine, just wanted to make sures you let session start first.  I would use the page load event.

Regards,

Aeros
0
 

Author Comment

by:HStrix
ID: 11801109
Thank you very much.
Ii is working now.
   
   HStrix
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question