Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Session on End to Fire

Status
Not open for further replies.

oldwen

Programmer
Dec 2, 2003
23
US
Hello all. I need some help with the Session on End. The code I have in place will not execute on an outside server (the external company that host my site). It does however execute fine on my local machine webserver. I am setting the time out property on my ASP app to one minute and it does time out, but the session on end code does not execute. Here is my code.

sub Session_OnEnd
Application.Lock
Application("visitors")=Application("visitors")-1
Application.UnLock

dim strLogFilePath

strLogFilePath = "D:\Inetpub\
Dim objFSO, objFile
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strLogFilePath, 8, True)
Set objFSO = Nothing
objFile.WriteLine "Session: " & Session.SessionID & " ended at " & Now ()
objFile.Close
Set objFile = Nothing

end Sub

Any ideas on what the problem is. Maybe and IIS issue. Please advise. Thank you for any help.
 
to mkae sure it fires call

session.abandon

I doubt that this path is correct on the real/live server...

strLogFilePath = "D:\Inetpub\
Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
You are correct, the path is different. I changed it for this example. The session does end with out using the session.abandon, because I am logged out after the time out occurs. But, still no write to the log file. Any ideas?
 
Make sure that the host is allowing writing (I_USER needs WRITE privilidges) to the folder where you are trying to keep your log.


Other than that, my guess is that you're not finding the logFile correctly. Are you using server.mapPath(relative URL) to assign the file name?


Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
I am able to write to the file in its current location by taking the same code and calling it from an ASP page. This is how I know that the session on end is not firing. Any ideas?
 
Not related to your problem, but you shouldn't lock and unloack the application anymore since IIS 5.0.

This...

Application.Lock
Application("visitors")=Application("visitors")-1
Application.UnLock

Should just be...

Application("visitors")= CLng(Application("visitors") - 1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top