Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Session TimeOut ...


Message #1 by "Melissa Mussitsch" <melissa.mussitsch@a...> on Thu, 30 May 2002 14:35:51
I am not using a Session Object with ASP, but just the Connection Timeout 
period set on the Web Site.  I wanted to know if there was a way to trap 
for the timeout so that I can display something friendlier than the 
typical "You are not authorized to view this page" page that gets 
displayed.

Any ideas?
Thanks.
Melissa Mussitsch
Message #2 by Oleg Kapeljushnik <c-oleg.kapeljushnik@w...> on Thu, 30 May 2002 11:06:40 -0400
Hi Mellisa !

I didn't find anyway to do it :(.

What I am doing is set some function to be executed when this timeout
time passed. The tricky thing here is that this function must to be reset
every time when new page are requested from the server since this timeout
start countdown from last page request.

Let me know if you find some better and simplest solution from mine
cause I know that its works so far but I defiantly would like
to improve it.

Oleg.

-----Original Message-----
From: Melissa Mussitsch [mailto:melissa.mussitsch@a...]
Sent: May 30, 2002 10:36 AM
To: ASP Web HowTo
Subject: [asp_web_howto] Session TimeOut ...


I am not using a Session Object with ASP, but just the Connection Timeout
period set on the Web Site.  I wanted to know if there was a way to trap
for the timeout so that I can display something friendlier than the
typical "You are not authorized to view this page" page that gets
displayed.

Any ideas?
Thanks.
Melissa Mussitsch

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20

Message #3 by "Debreceni, David" <david_debreceni@r...> on Thu, 30 May 2002 11:25:41 -0400
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C207EE.42523590
Content-Type: text/plain;
	charset="iso-8859-1"

This is what we use to redirect users when their session times out.  It is
just a javascript, but it works and will reset everytime the page is
refreshed.

//Code for the session timer
        var mytime = 0;
        var mysecs = 0;
        var Errormsg = "Your session has timed out."

        function sessionTimer() {
                mysecs++
                if (mysecs == 60) {
                        mytime++;
                        mysecs = 0;
                }
                setTimeout("sessionTimer()", 1000);
                if (mysecs < 10) {
                        defaultStatus = "Session Time: " + mytime + ":0" +
mysecs;
                        window.Status += "Session Time: " + mytime + ":0" +
mysecs;
                }
                else
                {
                        defaultStatus = "Session Time: " + mytime + ":" +
mysecs;
                        window.Status += "Session Time: " + mytime + ":" +
mysecs;
                }
                //Code for the redirect
                if (mytime >= timeOut) {
                        window.location 
"http://yourdomain/errorpage.asp?ErrorMsg=" + Errormsg;
                }

        }
        sessionTimer();

hope that helps

David Debreceni
Senior Visual Basic/ASP Developer
xxx-xxx-xxxx  x 1086


-----Original Message-----
From: Oleg Kapeljushnik [mailto:c-oleg.kapeljushnik@w...]
Sent: Thursday, May 30, 2002 11:07 AM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Session TimeOut ...


Hi Mellisa !

I didn't find anyway to do it :(.

What I am doing is set some function to be executed when this timeout
time passed. The tricky thing here is that this function must to be reset
every time when new page are requested from the server since this timeout
start countdown from last page request.

Let me know if you find some better and simplest solution from mine
cause I know that its works so far but I defiantly would like
to improve it.

Oleg.

-----Original Message-----
From: Melissa Mussitsch [mailto:melissa.mussitsch@a...]
Sent: May 30, 2002 10:36 AM
To: ASP Web HowTo
Subject: [asp_web_howto] Session TimeOut ...


I am not using a Session Object with ASP, but just the Connection Timeout
period set on the Web Site.  I wanted to know if there was a way to trap
for the timeout so that I can display something friendlier than the
typical "You are not authorized to view this page" page that gets
displayed.

Any ideas?
Thanks.
Melissa Mussitsch

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20



---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20

Message #4 by "Alex Shiell, ITS, EB, SE" <alex.shiell@s...> on Thu, 30 May 2002 16:48:05 +0100
I prefer to prevent the session from timing out while the application is on
the screen, by using this line

<META HTTP-EQUIV="refresh" CONTENT="<%=((session.Timeout * 60)-10)%>">
 
 -----Original Message-----
From: Debreceni, David [mailto:david_debreceni@r...]
Sent: 30 May 2002 16:26
To: ASP Web HowTo
Subject: [asp_web_howto] RE: Session TimeOut ...


This is what we use to redirect users when their session times out.  It is
just a javascript, but it works and will reset everytime the page is
refreshed.
//Code for the session timer 
        var mytime = 0; 
        var mysecs = 0; 
        var Errormsg = "Your session has timed out." 
        function sessionTimer() { 
                mysecs++ 
                if (mysecs == 60) { 
                        mytime++; 
                        mysecs = 0; 
                } 
                setTimeout("sessionTimer()", 1000); 
                if (mysecs < 10) { 
                        defaultStatus = "Session Time: " + mytime + ":0" +
mysecs; 
                        window.Status += "Session Time: " + mytime + ":0" +
mysecs; 
                } 
                else 
                { 
                        defaultStatus = "Session Time: " + mytime + ":" +
mysecs; 
                        window.Status += "Session Time: " + mytime + ":" +
mysecs; 
                } 
                //Code for the redirect 
                if (mytime >= timeOut) { 
                        window.location 
"http://yourdomain/errorpage.asp?ErrorMsg=" + Errormsg; 
                } 
        } 
        sessionTimer(); 
hope that helps 
David Debreceni 
Senior Visual Basic/ASP Developer 
xxx-xxx-xxxx  x 1086 


-----Original Message----- 
From: Oleg Kapeljushnik [mailto:c-oleg.kapeljushnik@w...] 
Sent: Thursday, May 30, 2002 11:07 AM 
To: ASP Web HowTo 
Subject: [asp_web_howto] RE: Session TimeOut ... 


Hi Mellisa ! 
I didn't find anyway to do it :(. 
What I am doing is set some function to be executed when this timeout 
time passed. The tricky thing here is that this function must to be reset 
every time when new page are requested from the server since this timeout 
start countdown from last page request. 
Let me know if you find some better and simplest solution from mine 
cause I know that its works so far but I defiantly would like 
to improve it. 
Oleg. 
-----Original Message----- 
From: Melissa Mussitsch [mailto:melissa.mussitsch@a...] 
Sent: May 30, 2002 10:36 AM 
To: ASP Web HowTo 
Subject: [asp_web_howto] Session TimeOut ... 


I am not using a Session Object with ASP, but just the Connection Timeout 
period set on the Web Site.  I wanted to know if there was a way to trap 
for the timeout so that I can display something friendlier than the 
typical "You are not authorized to view this page" page that gets 
displayed. 
Any ideas? 
Thanks. 
Melissa Mussitsch 
--- 
Improve your web design skills with these new books from Glasshaus. 
Usable Web Menus 
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme 
r-20 
Constructing Accessible Web Sites 
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme 
r-20 
Practical JavaScript for the Usable Web 
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme 
r-20 
--- 



--- 
Improve your web design skills with these new books from Glasshaus. 
Usable Web Menus 
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme 
r-20 
Constructing Accessible Web Sites 
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme 
r-20 
Practical JavaScript for the Usable Web 
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme 
r-20 
--- 
--- Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20 Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20 Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20 --- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to  

________________________________________________________________________
Scottish Enterprise Network
http://www.scottish-enterprise.com

Headquarters Address & Contact Numbers

150 Broomielaw
5 Atlantic Quay
Glasgow
G2 8LU.
Tel:  +44 (0) 141 248 2700.
Fax:  +44 (0)141 221 3217

 This message is sent in confidence for the addressee only.
It may contain legally privileged information. The contents are not to
be disclosed to anyone other than the addressee. Unauthorised recipients
are requested to preserve this confidentiality and to advise the sender
immediately of any error in transmission.


Message #5 by "Bill Todd" <btodd@a...> on Fri, 31 May 2002 00:46:23
A technique I discovered (and I've forgotten where) uses the transaction-
based nature of ASP like so:

Add this as the irst line in the script:
<%@ TRANSACTION=Required%>

(In my case this replaced this line, <%@ Language=VBScript %>, since you 
can have only one <%@ line in a script)

The add a Sub like so:
<%
Sub OnTransactionAbort()
  vPageName = request.servervariables("HTTP_HOST") & 
request.servervariables("SCRIPT_NAME")
  vQueryString = REPLACE(request.servervariables("QUERY_STRING"),"|-
|ASP_0113|Script_timed_out","")
  IF vQueryString <> "" THEN
    vQueryString = "?" & vQueryString 
  END IF
  err = 0
  Set objCDO = Nothing
  Set objCDO = Server.CreateObject("CDONTS.NewMail")
  objCDO.To = "SUPPORT@Y..."
  objCDO.CC = ""
  objCDO.BCC = ""
  objCDO.From = "webmaster@s..."
  objCDO.Subject = "Timeout on SOC page " & vPageName
  objCDO.Importance = 2
  vBody=""
  vBody=vBody & "Script Timeout" & chr(13)
  vBody=vBody & "Server Date/Time: " & FormatDateTime(Now) & chr(13) & chr
(13)
  vBody=vBody & "PAGE/QUERY STRING: " & vPageName & vQueryString & chr(13) 
& chr(13)
  vBody=vBody & "Browser/Op Sys: " & request.servervariables
("HTTP_USER_AGENT") & chr(13) & chr(13)
  vBody=vBody & "Vistor IP: " & request.servervariables("REMOTE_ADDR") & 
chr(13)
  vBody=vBody & "Server IP: " & request.servervariables("LOCAL_ADDR") & chr
(13)
  objCDO.Body = vBody
  objCDO.BodyFormat = 1
  objCDO.MailFormat = 1
  objCDO.Send
  Set objCDO = Nothing

  response.redirect "http://<INSERT YOUR BACKUP SERVER DOMAIN HERE>" & 
request.servervariables("SCRIPT_NAME") & vQueryString

end sub
%>

Since a timeout causes the asp transaction to abort, the logic in the sub 
will be executed. You can code whatever you like there - I set it up to 
send me an email with the timeout details and redirect the user to a 
mirror site.

If you have problems contact me off-list at webmaster@a... since I 
don't always follow the threads here.

 Bill

 

  Return to Index