473,569 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Global.asa - Session_OnEnd Question ..

Hi Folks,

I'm having a hard time getting my Session_OnEnd event to fire in my
global.asa.
Here's what I have:

<SCRIPT LANGUAGE=VBSCRI PT RUNAT=Server>
SUB Session_OnStart
Session.TimeOut = 30
END SUB

Sub Session_OnEnd
Response.Redire ct("http://mydomain.com/mylogin.asp")
End Sub
</SCRIPT>

I made a simple page to call the session.abandon - to test the OnEnd event.
But it doesn't fire. I have set the session.timeout to 1 and also waited for
the default 20 to pass. I just can't get that redirect to occur when the
session ends.

I know the global.asa is set up properly, because the OnStart event WILL
fire if I move my redirect statement to the SUB Session_OnStart routine.

Thanks very much for any help.

Clear Skies,
Jack Coletti

Jul 19 '05 #1
6 9507
But obvously this guy's browser was not closed in this case, because he was
testing to see if the redirection would occur.
http://www.aspfaq.com/2078

this article say that there is a bug, not that his test should fail because
his computer might be turned off.

Ray is at <%=sLocation% >" but the lights are off

"Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message
news:uR******** ******@tk2msftn gp13.phx.gbl...
I suggest you do something a little different, like:

Sub session_onstart ()
session("active ") = true
End Sub

And then use something like
If Not(session("ac tive")) Then response.redire ct "/mylogin.asp"
See here for the reasons.
http://www.aspfaq.com/2078

When the session ends, the browser could be closed, and the user's computer may even be turned off, unplugged, and thrown away. How could you do a
redirect then?

Ray at home
--
Will trade ASP help for SQL Server help
"MostlyH2O" <ja*********@TA KEOUTTHECAPITAL Sbaylife2000.co m> wrote in message news:XU******** **************@ twister.tampaba y.rr.com...
Hi Folks,

I'm having a hard time getting my Session_OnEnd event to fire in my
global.asa.
Here's what I have:

<SCRIPT LANGUAGE=VBSCRI PT RUNAT=Server>
SUB Session_OnStart
Session.TimeOut = 30
END SUB

Sub Session_OnEnd
Response.Redire ct("http://mydomain.com/mylogin.asp")
End Sub
</SCRIPT>

I made a simple page to call the session.abandon - to test the OnEnd

event.
But it doesn't fire. I have set the session.timeout to 1 and also waited

for
the default 20 to pass. I just can't get that redirect to occur when the session ends.

I know the global.asa is set up properly, because the OnStart event WILL
fire if I move my redirect statement to the SUB Session_OnStart routine.

Thanks very much for any help.

Clear Skies,
Jack Coletti


Jul 19 '05 #2
Actually what I meant to say is that Ray was right, but you have to read the
Entire article- just like I keep saying.

"Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message
news:uR******** ******@tk2msftn gp13.phx.gbl...
I suggest you do something a little different, like:

Sub session_onstart ()
session("active ") = true
End Sub

And then use something like
If Not(session("ac tive")) Then response.redire ct "/mylogin.asp"
See here for the reasons.
http://www.aspfaq.com/2078

When the session ends, the browser could be closed, and the user's computer may even be turned off, unplugged, and thrown away. How could you do a
redirect then?

Ray at home
--
Will trade ASP help for SQL Server help
"MostlyH2O" <ja*********@TA KEOUTTHECAPITAL Sbaylife2000.co m> wrote in message news:XU******** **************@ twister.tampaba y.rr.com...
Hi Folks,

I'm having a hard time getting my Session_OnEnd event to fire in my
global.asa.
Here's what I have:

<SCRIPT LANGUAGE=VBSCRI PT RUNAT=Server>
SUB Session_OnStart
Session.TimeOut = 30
END SUB

Sub Session_OnEnd
Response.Redire ct("http://mydomain.com/mylogin.asp")
End Sub
</SCRIPT>

I made a simple page to call the session.abandon - to test the OnEnd

event.
But it doesn't fire. I have set the session.timeout to 1 and also waited

for
the default 20 to pass. I just can't get that redirect to occur when the session ends.

I know the global.asa is set up properly, because the OnStart event WILL
fire if I move my redirect statement to the SUB Session_OnStart routine.

Thanks very much for any help.

Clear Skies,
Jack Coletti


Jul 19 '05 #3
It is late on a Sunday night (in the easter time zone anyway). You should
not be drunk. ;]

Ray at home

--
Will trade ASP help for SQL Server help
"Roy in <%=H.E.Double Toothpicks $>" <Ro*@DoubleToot hpicks.com> wrote in
message news:ef******** ******@tk2msftn gp13.phx.gbl...
Actually what I meant to say is that Ray was right, but you have to read the Entire article- just like I keep saying.

"Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message
news:uR******** ******@tk2msftn gp13.phx.gbl...
I sugge

Jul 19 '05 #4
Ah yes the easter time zone, where every morning chocolate eggs are found
scattered throughout the home.

If the Session has ended, then the user hasn't requested anything from the
server. Since the server can't send anything to the client without a
request, you won't be able to redirect anywhere.

If the user was browsing around your site then his Session("Active ") ="true"
as set in Session_OnStart . Then he goes for a nap and his session times
out. As soon as he clicks on a link or refreshes his screen, his
Session("Active ") will again be set to "true" as a new session will have
begun.
The response.redire ct will never be called in the Session_OnEnd.

If the goal is merely to ensure someone is logged in and their session is
active. It would be more logical to set the Session("Active ")=true in the
login processing page, then checking that it's still valid at the top of
every page--a good job for an #include.


"Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message
news:Os******** ******@TK2MSFTN GP12.phx.gbl...
It is late on a Sunday night (in the easter time zone anyway). You should
not be drunk. ;]

Ray at home

--
Will trade ASP help for SQL Server help
"Roy in <%=H.E.Double Toothpicks $>" <Ro*@DoubleToot hpicks.com> wrote in
message news:ef******** ******@tk2msftn gp13.phx.gbl...
Actually what I meant to say is that Ray was right, but you have to read

the
Entire article- just like I keep saying.

"Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message
news:uR******** ******@tk2msftn gp13.phx.gbl...
I sugge


Jul 19 '05 #5
I'm going to assume what you are trying to accomplish is to require the user
to log back in after a period of inactivity. As was pointed out in previous
posts, this can not be accomplished using the Session_OnEnd sub in the
global.asa file.

The method I use for this is to simply use a meta element in HTML and
redirect the browser after a period of time equivalent to my session timeout
on the server. I redirect to a page informing the user that their session
has timed out.

On the page I want to timeout, I put:
<% strThisPageURL = "http://" & Request.ServerV ariables("SERVE R_NAME") &
Request.ServerV ariables("URL")
<meta http-equiv="refresh" content="1200; URL=<% Response.Write "http://" &
Request.ServerV ariables("SERVE R_NAME") & "/ExpiredLogIn.as p?U=" &
strThisPageURL %>">

The page ExpiredLogIn.as p is:
<html>
<head>
<title>Log-In Expired</title>
</head>
<%If Not IsEmpty(Request .QueryString("U ")) Then strPreviousPage URL =
Request.QuerySt ring("U")%>
<body>
<p align="center"> &nbsp;</p>
<h3 align="center"> Your Log-in has expired due to inactivity.</h3>
<h3 align="center"> If you wish to log-in again, click <a
href="LogInForm .asp?U=<%=strPr eviousPageURL%> ">here</a>.</h3>
</body>
</html>

And in my login page, it looks for the QueryString for the URL of the timed
out page and redirects there after a successful login.

HTH
Mark
Jul 19 '05 #6
Thanks for all the help, good people.

Yes, I would have toiled for days trying to get the global.asa to redirect
the user to the login page after the session timed out. And, I *was* trying
to avoid checking the session state at the top of each of the 47 pages that
make up my utility.

Thanks for setting me straight :-)

Clear Skies,
Jack Coletti
Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2463
by: Soha El-Saeed | last post by:
Dear All; I wrote this code in the global.asa but it dosen't work inspite that it works in any asp file and also in the global.asa file but only in the session_onstart part.This code is to delete a txt file at the end of the session.The file was created during the user's session and has the name of the session id. The session variable...
11
2182
by: Julian | last post by:
Hi I have code in my login.asp which sets the online field in user database to true or 1. I am trying to use the same code in global.asa to change back the online field to 0 but it doesn't work. The code is very simple and it should work, any idea why it doesn't? Sub Session_OnEnd If Session("User_ID")<>" " Then ' check if...
3
3698
by: cab | last post by:
i have the following code in the "Sub Session_OnEnd" routine that does not seem to run..... Sub Session_OnEnd strConnect = "Driver={SQL Server};Server=SERVER;Database=database; User ID=xxxxxx;Pwd=xxxxxxx" Set objConnEnd = Server.CreateObject("ADODB.Connection") objConnEnd.Open strConnect
24
2441
by: Nancy Drew | last post by:
hi all i'm trying to keep users from being able to login to a site twice at the same time. everytime a user does a login, i stick their userID into an application scoped array. if they try to login again, i bounce them to an error page. i use the session_onEnd sub within global.asa to remove their userID from the array at the end of their...
4
6783
by: Propin | last post by:
Have a problem with below code in global.asa. Same problem as described in this news group before, IWAM_machinename did not solve my problem. Have created the following test code (file is never deleted on my IIS6 Win2003 environment, any idea?): <SCRIPT LANGUAGE="VBScript" RUNAT="Server"> Sub Application_OnStart End Sub
28
4862
by: Prabhat | last post by:
Hello, I have the below requirement. When ever my website is opened by any link: say clicked from the google search result or a link from other website: Then I should able to know the referrer URL. How Do I get that? I know about Request.ServerVariables("HTTP_REFERER"). So I used this in
5
3932
by: WJ | last post by:
I am attempting to use the Global.Asax to store my user's configuration. Here is the concept: 1. User logs on into the site using Form Authentication. 2. I capture the user Credential, verify it and then assign this Logon ID (user) a so called User's serverside cookie. 3. My system is configured to accept 1,024 concurrent users, this means...
11
2084
by: David Thielen | last post by:
Hi; Is there some kind of session ID variable that I can get in the code behind and that is available in Session_OnEnd() to know what session ended? -- thanks - dave david_at_windward_dot_net http://www.windwardreports.com
1
2251
by: u0107 | last post by:
Hello, I am developing a website with an MS-Access backend database. One of the tables in the database is tblUser. On accessing my website, a user is required to provide a valid user id and a password. Once a user id and password is provided, it is validated against appropriate fields in tblUser and a "logged in" flag (another field in...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6286
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.