Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session.Timeout Settings 1

Status
Not open for further replies.

requested89

IS-IT--Management
Sep 6, 2005
44
GB
Apologies for asking what is a fairly simple question but I couldn't find the answer anywhere.

I have an area of my website where people have to login and can then write text etc. If the person is writing for 30 minutes and then click submit, the session has timed out and all their work is lost. I want to prevent this.

I have 4 questions:

1) I create a session which dictates whether or not the user is logged in. Am I correct in assuming that this session variable is deleted when Session_End is fired i.e. when there has been no activity for 20 mins for example?

2) Is it possible to alert the user that they will be logged out in X amount of time. I'm guessing not without the use of a JavaScript timer or similar but thought I'd ask just in case.

3) Where exactly is the best place to set the session.timeout value. The session.timeout value is not relevant in any of the site except the restricted area so should I set it manually on each of the restricted pages or just set it in the Web.Config file?

4) What is the syntax for setting it in the Web.Config file?

Thanks in advance,

Chris
 
1) Yes

2) Again, you are correct - the server times out if it doesn't receive a response in x minutes so you would have to use a client timer (e.g. javascript) if you wanted to show the amount of time since the last response.

3) I'd say the web.config file in this scenario

4) An example would be:
Code:
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20" />
Note: The timeout property is in minutes


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Cool thanks for your answer ca8msm. You've come to my aid a few times before.

Can you just gimme a bit more info on what the sessionState stuff means.

What is mode, stateConnectionString, sqlConnectionString, data source and cookieless?

It seems to me like I only need the timeout part of all this. Is this a fair assumption or are the others required? Also will having any of this in my Web.Config affect my maintain state stuff in the website i.e. when I do a post back and the state is maintained?

Thanks in advance

Chris
 
More info on the sessionState node can be found in your help files (if you have VS) or online at:


The example I gave above was just a default entry that VS had set up. The most important details for your scenario (or what I think it is!) will be setting the timeout property and the mode to "InProc" (which will keep you session data locally, and should answer your question about postbacks).



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Thanks thats solved my problems.

Incidentally I don't suppose you happen to know why, as soon as I implemented the change in my Web.Config, all my links have changed to a rather bizarre link.

For example before I changed the Web.Config my link was:


and now it has changed to:


Very strange indeed I think you'll agree. Is this usual?

Thanks in advance,

Chris.
 
Doesn't look at all normal to me! Do you mean you just had a standard anchor tag on your html page and that has been modified e.g.
Code:
<a href="[URL unfurl="true"]http://www.mysite.com/folder1/folder2/folder3/default.aspx">Click[/URL] Me</a>


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Yeah it seems to have done. All my links i.e. ones that are relative to the page and post-backs automatically have this weird extra folder included.

If I look at the source code however the links are still relative without the weirdness. In the source it says <a href="addContent.aspx" etc etc but if I role over the link in the browser (Safari, IE, Firefox) it displays:


Also it seems to be a random value. I have the page open in one browser on my Mac and one browser on my PC and the values are different.

Everything works the same so there is no actual problem but it isn't really ideal if it is an anomaly.

Any ideas?

Thanks in advance,

Chris
 
To be honest, I've never had anything like that happen to me so I'm not sure what to suggest (it looks like a session id though)! You could try restarting VS (if that's what you are developing in) as that has some unusual quirks!




____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I think I know what it was. I had set it in the following way:

Code:
<sessionState mode="InProc" cookieless="true" timeout="60"/>
 
AMENDMENT TO ABOVE

I think the cookieless="true" meant the application had to keep track of the session in the URL rather than with a Cookie.

Thanks for your help,

Chris
 
Although I have resolved the weird URL problem my Session.Timeout still isn't being increased.

Do you know whether or not there is a setting on the server whereby the TimeOut cannot be set above the time set by the IIS perhaps? I know that with ASP Classic you couldn't set the script.timeOut to any value below that set by IIS. Perhaps there is a similar thing with Session. Sounds highly unlikely to me but worth asking.

Thanks in advance,

Chris
 
I was curious if you happened to find some code to handle the javascript timer. I'm needing to do the same thing with my app and wasn't sure where to begin.

Thanks,

Shey
 
No I didn't even try. I figured that the JavaScript timer wouldn't be very accurate and over 20 minutes or so it would probably be 3-4 minutes out which kinda defeats the object. Especially if the clock is slower than the Server clock and the session timesout 2 minutes before the JavaScript announces it.

As well as the above issue having a JS timer going for 2 minutes just wastes system resources.

Let me know if you do come up with a solution though.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top