Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic 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 June 3rd, 2004, 10:57 AM
Authorized User
 
Join Date: Oct 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Timeout?

When an application times out, what variables should be cleared for the user to log in again without having to close the browser?

The reason I'm asking is I have an app that has been set to timeout the user, but when logging back in, it does not correctly redirect to the page where the user was before he got logged out.

I have a feeling that this is because the server is accessing cached variables/information and I'm not sure how to fix it.

Any ideas?

 
Old June 3rd, 2004, 11:18 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

How about inserting something like this into the top of your page. Or maybe an SSI that you can include at the top of your pages.

<%
response.buffer = true

'--redirect to login if session is expired--
if Session("MySession") <> Session.SessionId then
    Session("MySession") = Session.SessionId
    response.redirect "Login.asp"
end if
%>

Only make sure you are redirecting to the correct page. As far as directing the user to the page he timed out at you could try setting a cookie when they enter a page that has the page info and then retrieve those page values after you have authenticated them.

That help?

Dave
 
Old June 3rd, 2004, 11:50 AM
Authorized User
 
Join Date: Oct 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by DaveGerard
 As far as directing the user to the page he timed out at you could try setting a cookie when they enter a page that has the page info and then retrieve those page values after you have authenticated them.

That help?

Dave

It might. Would there be any other way to retrieve the page info? Say, somehow connect the old session id (the arbitrary one issued by the server to keep track of session variables) to the new session id?

Actually now that I think about it, I think it has something to do with the database connections, since they depend on information established during login.

 
Old June 3rd, 2004, 06:42 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

To end a session immediately, you may use the Abandon method:
<%
Session.Abandon
%>

To remove all variables in a session, use the RemoveAll method:
<%
Session.Contents.RemoveAll()
%>

To remove a session var:
<%
Session.Contents.Remove("varName")
%>


My Opinion: Cookies should remain something you eat. Advances in server side code have left you very few occasions when you may need to use them Eg 'tick this box to remember my log in details'. Using cookies inhibbits the portability of your web pages. Use then but dont rely on them. If you do rely on them, you are restricting your viewable audience.

Have you got your time out set to less than the default 20 mins? if so, you are restricting your users from making a cofee and being able to come back to your web page to continue thier experience on your site. A personal turn off for me

Lastly, it's mostly frugal people who say session vars are bad and exhaustive on resources, true they are but - there are things you can do to make the use of them effectivly, i'll let you research that one (EG clear them once youve finished with them)
Solution, instead use:
a.. Constants
b.. hidden form variables
c.. Querystrings


Wind is your friend
Matt
 
Old June 4th, 2004, 05:30 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

You could put together some code that would write the page path (Query String) to a table and date it. You would also need to write their UserId. Then upon re-logging in you would query the last page that user accessed and send them to it. The code could be an SSI (include file) that you include in the top of each page (or parent page if using includes already). That way you only need write it once.

Dave






Similar Threads
Thread Thread Starter Forum Replies Last Post
timeout badboy1 ASP.NET 3.5 Basics 5 August 3rd, 2008 04:36 AM
Session Timeout aspless Classic ASP Basics 1 February 21st, 2008 04:46 PM
Search timeout...... Snib Forum and Wrox.com Feedback 4 May 28th, 2007 06:00 AM
Timeout Expires bob_rainhail SQL Server 2000 18 October 17th, 2006 10:29 AM
session timeout bikki_suresh ASP.NET 1.0 and 1.1 Basics 0 October 10th, 2006 12:16 AM





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