Results 1 to 9 of 9

Thread: session_OnEnd

  1. #1
    Prashanth Guest

    Default session_OnEnd

    Hello,<BR>I have to clean-up some table as soon as the session ends. I have written a code which goes like this<BR><BR>session_onEnd()<BR>id=session.sessionI d<BR>sql="delete from mytable where customerid="&id<BR>conn.execute sql<BR>end sub<BR><BR>But it seems there is some problem with this .can u please find solution for this?<BR><BR>Thanks in advance<BR>Prashanth<BR><BR>

  2. #2
    Jim Andrews Guest

    Default RE: session_OnEnd

    Maybe you could specify what kind of problem you&#039re having? That makes for slightly easier troubleshooting...

  3. #3
    Prashanth Guest

    Default RE: session_OnEnd

    Hi,<BR>Well, Let me explain in detail. I have got to delete some records of &#039temp&#039 table as soon as the users session_ends . For that in global.asa i have written code which is suppose to delete the records. The prototype goes like this.<BR><BR>Session_OnEnd()<BR>sid=session.sessio nId<BR>mySql="Delete from Temp where customerId="&Sid<BR>myconn.execute<BR>end sub<BR><BR>But this doesnt works. The records will be still there after the session_end also<BR><BR>Can u please suggest me something<BR>Thanks<BR>Prashanth

  4. #4
    Lasker Guest

    Default RE: session_OnEnd

    Sorry to disappoint you .. but there is no way you can do a database manipulation through Session_onEnd.<BR><BR>But, hey .. please correct me if I am wrong .. I would love to know that I am wrong .. coz I faced this problem before :)

  5. #5
    Join Date
    Dec 1969

    Default RE: session_OnEnd

    You can do what you like at the end of a session.<BR>It is an event like any other.<BR><BR>But as it is only called when the user has lost session state there can never be an associated sessionid.

  6. #6
    Prashanth Guest

    Default RE: session_OnEnd

    Thankx <BR>but is there Any way to grab sessionid to manipulation?<BR><BR>Bye<BR>Prashanth

  7. #7
    Akram Guest

    Default ONEND -- Its possible...

    Prashanth,<BR><BR>I have tried out deleting the data from the tables in Session_Onend event.. it works fine.. its possible to delete the data from the table wrt the SessionID (provided u have this stored in the table).. but its not advisable to delete data wrt SessionID, as IIS docs indicate that sometimes web server creates duplicate ID&#039s..<BR><BR>the on-end event fires only when the timeout period is over.. by default, only after 20 mins, this event is fired. try using session.abandon explicitly.. the on-end event fires.. u can even set the timeout value from an asp page..<BR><BR>u can get the sessionID with the statement Session.SessionID<BR>Check it out..<BR><BR><BR><BR><BR><BR>

  8. #8
    geeoff Guest

    Default RE: ONEND -- Its possible...

    Akram is right and also simply closing your browser does not initiate the Session_OnEnd event. I would put Session.Abandon as the last piece of code in the page where you are doing the database processing from once Session.Abandon is processed the Session_OnEnd sub will be called. You can also set Session.Timeout = 1 &#039[in minutes] in your Session_OnStart sub, since the default is 20 minutes you will not see the desired DB deletions for that amount of time. I have scripts that do tons of cleanup work similar to this after the user&#039s session ends. Works great.

  9. #9
    Matt Woodward Guest

    Default RE: session_OnEnd

    I&#039m doing the following successfully on PWS connecting to SQL Server 7:<BR><BR>Sub Session_OnEnd<BR> Set Conn = Server.CreateObject ("ADODB.Connection")<BR> Conn.ConnectionString = "DSN=xxx;UID=xxx;PWD=xxx;"<BR> Conn.Open<BR> Set rstemp = Server.CreateObject ("ADODB.Recordset")<BR> strSql = "sp_set_online &#039" & Session("IDforonline") & "&#039,&#0390&#039" <BR> Set rstemp = Conn.Execute(strSql)<BR> Session.Abandon<BR>End Sub<BR><BR>Now if I could just get my global.asa working on IIS ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts