Global.asa and Session_OnEnd

Discussion in 'ASP General' started by Soha El-Saeed, Feb 4, 2004.

  1. 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
     
    Soha El-Saeed, Feb 4, 2004
    #1
    1. Advertising

  2. "Soha El-Saeed" <> wrote in message
    news:...
    > 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
     
    John Blessing, Feb 4, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MostlyH2O

    Global.asa - Session_OnEnd Question ..

    MostlyH2O, Jul 28, 2003, in forum: ASP General
    Replies:
    6
    Views:
    157
    MostlyH2O
    Jul 28, 2003
  2. Olivier SOW

    session_OnEnd dans le global.asa never fired

    Olivier SOW, Oct 27, 2004, in forum: ASP General
    Replies:
    6
    Views:
    184
    Bob Barrows [MVP]
    Oct 28, 2004
  3. Bill

    Global.asa and Session_OnEnd

    Bill, Feb 11, 2005, in forum: ASP General
    Replies:
    4
    Views:
    131
  4. steven scaife

    Global.asa Session_OnEnd

    steven scaife, Sep 1, 2005, in forum: ASP General
    Replies:
    3
    Views:
    173
    Evertjan.
    Sep 2, 2005
  5. global.asa @ Session_OnEnd

    , Jul 13, 2006, in forum: ASP General
    Replies:
    1
    Views:
    130
    Mike Brind
    Jul 13, 2006
Loading...

Share This Page