Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional 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 April 12th, 2007, 09:04 AM
Authorized User
Points: 483, Level: 7
Points: 483, Level: 7 Points: 483, Level: 7 Points: 483, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2007
Location: Edgewood, NY, USA.
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sessions dont work

Hi. I am a beginner here...

I want to simply have a session on a page for 30 minutes. After 30 minutes is up, to redirect to another .asp page.

Here is what I have:

<%Session.Timeout=30
if (Session.Timeout=0)then
%>
<%
Response.Redirect("cart_endsession.asp")
End If
%>

currently, it doesnt do a thing. Why?

 
Old April 12th, 2007, 09:24 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The TimeOut property of the session class "gets or sets the time the session is alive for". Not what the current time left is of a session. You need to solve this with javascript. Use the setTimeout js method and set the location.href property of the document.

-Peter
 
Old April 12th, 2007, 09:31 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

This is something that is continually asked on the forums; the short answer is that you can't. Instead of rehasing this again, read this thread:

http://p2p.wrox.com/topic.asp?TOPIC_ID=58564

It is in the 2.0 forum, but the same prinipal applies to you.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old April 12th, 2007, 10:08 AM
Authorized User
Points: 483, Level: 7
Points: 483, Level: 7 Points: 483, Level: 7 Points: 483, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2007
Location: Edgewood, NY, USA.
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, then how do I set the timeout on page one, and if a user goes to page two, page 2 timesout and redirects? can i do that with .asp timeout function?

 
Old April 12th, 2007, 10:22 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Ok. Here is your crash course in Session State.

For my example I will use your example of a session that lasts 30mins.

When I first enter a web application my session begins and the clock starts counting down. Now if I make another request to the application *that has to go to the server for processing (another asp page)* my session timeout will be reset again to 30mins.

Now, If i stay on one page and do nothing for 35 mins and then try to request a page that needs session variables or something of that sort, they will not be available as my session has timed out and the session object destoryed. As Peter suggested, using Javascript is the most effecient way to detect when X amount of time has elapsed on a particular page.

All you need to do is:

setTimeout(location.href='timeout.asp', 3000000)

After 30 mins has elapsed, the javascript location.href will be called and it will send your user to another page letting them know that their session has timed out.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old April 12th, 2007, 01:01 PM
Authorized User
Points: 483, Level: 7
Points: 483, Level: 7 Points: 483, Level: 7 Points: 483, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2007
Location: Edgewood, NY, USA.
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is what I need to do....

I want a session to start as soon as a user visits my products page that will give them 30 minutes to shop...
Then I need the "view cart" page to timeout after knowing the timer is more than 30 minutes, and redirect to a "you have been timed out" page.

Can this be done?

 
Old April 12th, 2007, 01:17 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Using purely asp? No. As peter and I have both said, you need to run a form of timer client side to generate this type of behavior. SetTimeout is just the type of timer you could use as it will raise a redirect when 30mins has expired.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========




Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Parts dont work on my PC savan_thakkar ASP.NET 2.0 Professional 0 October 10th, 2006 08:10 AM
*.do URLs dont work in apache web server+tomcat haomomo Struts 1 August 29th, 2006 09:57 AM
insert tigger dont work multiple kspiderman SQL Server 2000 1 October 21st, 2005 01:42 PM
Samples dont work Jags .NET Framework 2.0 1 April 22nd, 2005 09:39 AM
ch10 p 404 server.URLEncode dont work :( Timmo BOOK: Beginning ASP 3.0 0 February 3rd, 2004 03:44 PM





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