Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 6th, 2003, 09:47 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default Automatic Session Timeout

How can I get my program to time out and automatically take the users to the login screen? Sometimes a user logs in then sometimes they walk away still logged in. After being idle for 15 minutes I want the session to time out and automatically take them to a login screen. Just like any online banking session where it automatically logs you out and displays the login screen.

Thanks,
Judy
 
Old October 6th, 2003, 10:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Default

We have this line at the top of one of our pages that makes it refresh every 5 seconds. Change the 5 to 900 and that should get you to 15 minutes.
Code:
<META HTTP-EQUIV="refresh" content="5;">
When the page is loaded, check for login status and if not redirect them to the login page.
Make sure you set the session.timeout to 15 minutes and that should work.

Chris
 
Old October 6th, 2003, 02:08 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

Hi Chris,

This is what I did, copied your code and pasted it on the very top of my login.asp file. On the next line I did <% session.Timeout = 15%>. I waited for 17 mins and it still did not go back to the login screen. I had to click refresh for it to go back to the login screen. I checked for a session variable(SSN) if it is equal to spaces then I redirect it to the login screen.

This is what I originally have to use to check if it's been iddle for 15 mins I did not use session.timeout till now. The only problem with this is that if the users don't hit refresh, it does not trigger my session variable validation for spaces then go to login screen.

Where or which page should I be putting the refresh code and the session.timeout code?

Thanks,
Judy
 
Old October 6th, 2003, 02:13 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Default

put the code inside the <HEAD> tag. It automatically refreshes the page. I am not sure what is not working. Maybe set the number back to 5 and see if it refreshes in 5 seconds. I have a page that refreshes every 10 minutes and it works fine. I am in an entirely IE environment, so you may want to check browser compatability.

Chris
 
Old October 6th, 2003, 04:24 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

Hi Chris,

I placed it inside the head tag and it works. The only thing though is that it does not go to the login screen because what I check is a session variable. Even though the session times out (or does it really times out?) it still has the session Variable(SSN) information which is why checking Session("SSN") = "" is not going to redirect to the login screen. Is there another way to check whether the session has timed out aside from checking session variables? Ex. If Session.Timeout = "True" Then redirect to login.asp end if. I tried this though and it did not work. Probabaly because I really do not know how to check for session.timeout.

Thanks for your help,
Judy
 
Old October 6th, 2003, 05:40 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Default

maybe it is refreshing just before the timeout occurs and refreshes the timeout.

The timeout is default set to 20 minutes, so make sure it is changed.

Maybe at the top of your screen set the session.timeout to 1 (for a 1 minute test) then have the page refresh after 2 minutes (120 in the header tag) and see if that works.

Chris
 
Old October 7th, 2003, 07:40 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

Hi Chris,

It is working. The mistake I did was putting the session.timeout on just the login.asp page and not on all the pages. I thought that if you put the session.timeout in just the default page, this should be enough. I will just put it on all my asp file. Thank you for your help as always you pull through for me.

Cheers,
Judy
 
Old October 7th, 2003, 09:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you should only have to have it on one page. Once it runs, it is valid for the session.

Chris





Similar Threads
Thread Thread Starter Forum Replies Last Post
Session Timeout aspless Classic ASP Basics 1 February 21st, 2008 04:46 PM
Session Timeout innochig ASP.NET 2.0 Professional 1 May 23rd, 2007 01:03 PM
Session timeout... rupen Classic ASP Professional 1 January 3rd, 2007 09:35 AM
session timeout bikki_suresh ASP.NET 1.0 and 1.1 Basics 0 October 10th, 2006 12:16 AM
Session Timeout lcsgeek Classic ASP Basics 1 October 6th, 2003 01:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.