Global.asa and Session_OnEnd

S

Soha El-Saeed

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 "session("mpath")" is
the varible which will hold the path of the created file. This is my
first question also I want to know how to set the session.timeout and
where to place it in the code?


<SCRIPT LANGUAGE=VBScript RUNAT=Server>
sub session_onstart
session("id")=0
session("mpath")=""

end sub

sub session_onend
set fsoglob=server.createobject("scripting.filesystemobject")
cpath=session("mpath")
set Cfolder=fsoglob.getfolder(cpath)

for each file in Cfolder.files

if instr(1,file.name,session.sessionid&".txt",1) then
fsoglob.deletefile(file)
end if
next
fsoglob.close
set fsoglob=nothing

end sub
</script>

Thank You
 
J

John Blessing

Soha El-Saeed said:
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 "session("mpath")" is
the varible which will hold the path of the created file. This is my
first question also I want to know how to set the session.timeout and
where to place it in the code?


<SCRIPT LANGUAGE=VBScript RUNAT=Server>
sub session_onstart
session("id")=0
session("mpath")=""

end sub

sub session_onend
set fsoglob=server.createobject("scripting.filesystemobject")
cpath=session("mpath")
set Cfolder=fsoglob.getfolder(cpath)

for each file in Cfolder.files

if instr(1,file.name,session.sessionid&".txt",1) then
fsoglob.deletefile(file)
end if
next
fsoglob.close
set fsoglob=nothing

end sub
</script>

Thank You

Session_onend is not reliable (http://www.aspfaq.com/show.asp?id=2078).
Plus, you are referring to session vars which don't exist by that time.

Instead, I would run a process on user login that deletes files which are
older than a specified amount.

You can place the session.timeout command in the Session_OnStart event.

--
John Blessing

http://www.LbeHelpdesk.com - Help Desk software priced to suit all
businesses
http://www.free-helpdesk.com - Completely free help desk software !
http://www.lbetoolbox.com - Remove Duplicates from MS Outlook
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top