Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 11:39 AM
Soha El-Saeed
Guest
 
Posts: n/a
Default Global.asa and Session_OnEnd

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.filesystemo bject")
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
  #2  
Old July 19th, 2005, 11:39 AM
John Blessing
Guest
 
Posts: n/a
Default Re: Global.asa and Session_OnEnd

"Soha El-Saeed" <selsaeed1@gawab.com> wrote in message
news:69069de6.0402032008.6a897071@posting.google.c om...[color=blue]
> 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.filesystemo bject")
> 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[/color]

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


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles