Link to home
Start Free TrialLog in
Avatar of eberglund
eberglund

asked on

Sessions Session_OnEnd.

Morning Experts.

I am trying to update a database when a user exists my application.  Problem is, sometimes users will not log out, they will leave the site, and the session will expire (after 20 minutes).

Now my question is, when the session_OnEnd is run, meaning a session is expired after timeout, or session.abandon, will  the session_OnEnd know what session is ending?

Meaning could I do the following.

SUB Session_OnEnd
StrSQL=" UPDATE alerts SET ShowAlert = '0' WHERE ShowAlert = '1' and ownerid ="'& Session("StrOwner")&"' "
End SUB

So the session that is about to be ended, can I pass the session StrOwner and update the database before the session has ended?

P.S.
I know this isnt how you would call the SQL script, and that alot of information is missing to do this correctly, I am leaving this information out to try to give you a clear and general idea of what I am trying to do.

Thanks to everyone.
Avatar of ap_sajith
ap_sajith

SUB Session_OnEnd
StrSQL=" UPDATE alerts SET ShowAlert = '0' WHERE ShowAlert = '1' and ownerid ='" Session("StrOwner")&"'"
End SUB

You can do that... The only problem is that session_OnEnd is not very reliable ie, it need not be triggreed everytime.

Cheers!!
ASKER CERTIFIED SOLUTION
Avatar of ap_sajith
ap_sajith

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eberglund

ASKER

Yes I have had problems with the session_OnEnd in the past.  What would be a better solution, short of writing  a script that checks session times every minute, and kills the session after x time period, where x is the set timeout.

I should also note that my application will only have a few (less then 30-50) people logged in at a time.



So up to the point beofore the sub routine ends (End sub causes the sub to execute correct), the session will keep in tack its session variables, along with knowing what session it is about to end.
Ya know, the application works the same way with session_onstart, dont know why I didnt think of this before, so it wont be as difficult then I thought.  thanks though.