Sub Session_OnEnd

Discussion in 'ASP General' started by cab, Jun 8, 2004.

  1. cab

    cab Guest

    i have the following code in the "Sub Session_OnEnd" routine that does not
    seem to run.....

    Sub Session_OnEnd

    strConnect = "Driver={SQL Server};Server=SERVER;Database=database; User
    ID=xxxxxx;Pwd=xxxxxxx"

    Set objConnEnd = Server.CreateObject("ADODB.Connection")
    objConnEnd.Open strConnect

    strDelete = "DELETE formdata WHERE formMyCpsID = " & Session.SessionID
    objConnEnd.Execute

    strDelete objConnEnd.Close
    Set objConnEnd = Nothing

    End Sub

    ....can I access the Session.SessionID at this stage or has it already been
    killed?

    cheers,
    cab.
     
    cab, Jun 8, 2004
    #1
    1. Advertising

  2. cab

    Evertjan. Guest

    cab wrote on 08 jun 2004 in microsoft.public.inetserver.asp.general:

    > i have the following code in the "Sub Session_OnEnd" routine that does
    > not seem to run.....
    >
    > Sub Session_OnEnd
    >
    > strConnect = "Driver={SQL Server};Server=SERVER;Database=database;
    > User
    > ID=xxxxxx;Pwd=xxxxxxx"
    >
    > Set objConnEnd = Server.CreateObject("ADODB.Connection")
    > objConnEnd.Open strConnect
    >
    > strDelete = "DELETE formdata WHERE formMyCpsID = " &
    > Session.SessionID objConnEnd.Execute
    >
    > strDelete objConnEnd.Close
    > Set objConnEnd = Nothing
    >
    > End Sub
    >
    > ...can I access the Session.SessionID at this stage or has it already
    > been killed?


    I don't know, but you could test this by global.asa:

    Sub Session_OnEnd
    application("testing") = Session.SessionID & "-!-"
    End Sub

    ===============
    In an asp-page test this with:

    if application("testing") = "" then
    respons.write "No session ended yet. Please try later."
    elseif application("testing") = "-!-" then
    respons.write "Session.SessionID not available in Session_OnEnd"
    else
    respons.write "Yes, Session.SessionID is available in Session_OnEnd"
    end if

    ================
    not tested ;-}


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jun 8, 2004
    #2
    1. Advertising

  3. You can't rely on this to fire anyway.

    http://www.aspfaq.com/2078
    http://www.aspfaq.com/2491

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "cab" <> wrote in message
    news:40c55fdb$...
    > i have the following code in the "Sub Session_OnEnd" routine that does not
    > seem to run.....
    >
    > Sub Session_OnEnd
    >
    > strConnect = "Driver={SQL Server};Server=SERVER;Database=database; User
    > ID=xxxxxx;Pwd=xxxxxxx"
    >
    > Set objConnEnd = Server.CreateObject("ADODB.Connection")
    > objConnEnd.Open strConnect
    >
    > strDelete = "DELETE formdata WHERE formMyCpsID = " & Session.SessionID
    > objConnEnd.Execute
    >
    > strDelete objConnEnd.Close
    > Set objConnEnd = Nothing
    >
    > End Sub
    >
    > ...can I access the Session.SessionID at this stage or has it already been
    > killed?
    >
    > cheers,
    > cab.
    >
    >
     
    Aaron [SQL Server MVP], Jun 8, 2004
    #3
  4. cab

    cab Guest

    it thought this might have been the case.
    i was testing my code below replacing the Session.SessionID with an actual
    value in the database.
    sometimes the database entry was deleted, but more often it was not.
    thanks.


    "Aaron [SQL Server MVP]" <> wrote in message
    news:u#...
    > You can't rely on this to fire anyway.
    >
    > http://www.aspfaq.com/2078
    > http://www.aspfaq.com/2491
    >
    > --
    > http://www.aspfaq.com/
    > (Reverse address to reply.)
    >
    >
    >
    >
    > "cab" <> wrote in message
    > news:40c55fdb$...
    > > i have the following code in the "Sub Session_OnEnd" routine that does

    not
    > > seem to run.....
    > >
    > > Sub Session_OnEnd
    > >
    > > strConnect = "Driver={SQL Server};Server=SERVER;Database=database; User
    > > ID=xxxxxx;Pwd=xxxxxxx"
    > >
    > > Set objConnEnd = Server.CreateObject("ADODB.Connection")
    > > objConnEnd.Open strConnect
    > >
    > > strDelete = "DELETE formdata WHERE formMyCpsID = " & Session.SessionID
    > > objConnEnd.Execute
    > >
    > > strDelete objConnEnd.Close
    > > Set objConnEnd = Nothing
    > >
    > > End Sub
    > >
    > > ...can I access the Session.SessionID at this stage or has it already

    been
    > > killed?
    > >
    > > cheers,
    > > cab.
    > >
    > >

    >
    >
     
    cab, Jun 9, 2004
    #4
    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. anand

    my session_onend is not working

    anand, Jul 9, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    1,386
  2. Hans Kesting

    Session variables and Session_OnEnd

    Hans Kesting, Aug 18, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    601
    Hans Kesting
    Aug 19, 2003
  3. steve
    Replies:
    0
    Views:
    417
    steve
    Aug 25, 2003
  4. Ben
    Replies:
    2
    Views:
    898
  5. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    2,043
    Lawrence D'Oliveiro
    May 20, 2011
Loading...

Share This Page