Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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 November 13th, 2003, 08:07 PM
Authorized User
 
Join Date: Jul 2003
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default UPDATE in Global.asa

I want to make an entry to the database when someone logs out of the site or their session times out. The following code located in the logout.asp file works fine when someone signs out, but this code in the global.asa file does not make an entry into the database on session timeout. When Session_OnEnd fires, does the SessionID still exist, or is it destroyed before the Session_OnEnd fires? Any other ideas?

Rich Hoffmann



Sub Session_OnEnd

    dim adoConnection
    set adoConnection = Server.CreateObject("ADODB.Connection")
    adoConnection.Open("DSN=RLCMembers")

    adoConnection.Execute("UPDATE LoginLog SET DateTimeOUT = Now() WHERE SessionID = '" + Session.SessionID + "';")

    adoConnection.Close()
    adoConnection = null


End Sub

__________________
Ego is a faithful friend; He stays with us all the way to the crater.
 
Old November 14th, 2003, 07:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

The SessionID still exists, but the problem is with the limitiations of Session_OnEnd - you can't use Server.CreateObject in there.
 
Old November 14th, 2003, 08:23 AM
Authorized User
 
Join Date: Jul 2003
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can I use Server.CreateObject in Session_OnStart? Assuming not, do I then Server.CreateObject elsewhere when the site loads and never null it until Session_OnEnd? Is there a problem with leaving it created like that? Can I open and close the connection in Session_OnEnd?

Thanks,
Rich

 
Old November 14th, 2003, 08:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Maybe there are some workarounds in here. http://www.aspfaq.com/show.asp?id=2078

Maybe you can just use CreateObject instead of Server.CreateObject?

Most folks steer clear of Session_OnEnd...

hth
Phil
 
Old November 14th, 2003, 10:37 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Like Phil says, Session_OnEnd = useless.

It doesn't fire reliably, if ever. I've never gotten it to work. The best you can really do is use the logout page that works.

Of course, this could also provide you with some statistical data. Any entries in the database that don't have a logout stamp, and are past the session length timelapse are users who didn't use the logout button! :)

From a symantec point of view, unless the use clicked "logout", they didn't really log out, they got booted out. :D

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 14th, 2003, 10:54 AM
Authorized User
 
Join Date: Jul 2003
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am wanting an easy way to see if it is safe to upload a new version of the database to the website. I was hoping to do that by looking at my "login" sheet, showing the login and logout time of all users. Since that depends on the user loggin out since Session_OnEnd doesn't work, I'm wondering what a good method is of seeing if others are logged into the system. I have seen the "user counter" sample program several places, but it also relies on Session_OnEnd. Will the below work any more reliably than what I have tried above?

sub session_onStart()

    application.lock()
    application("SCount") = application("SCount") + 1
    application.unlock()

end sub

sub session_onEnd()

    application.lock()
    application("SCount") = application("SCount") - 1
    application.unlock()

end sub

sub application_onStart()

    ' don't need a lock in onStart()
    application("SCount") = 0

end sub







Similar Threads
Thread Thread Starter Forum Replies Last Post
global.asa samwisegamgee16 Classic ASP Basics 1 September 25th, 2007 05:31 AM
About Global.asa pbcatan Classic ASP Databases 2 December 4th, 2006 12:40 AM
GLOBAL.ASA zaeem Classic ASP Databases 3 November 4th, 2003 09:13 AM
Global.asa madsmad ASP.NET 1.0 and 1.1 Basics 1 August 17th, 2003 07:05 PM





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