Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

fire logoff trigger as session expire

bamboat_3Sep 21 2011 — edited Mar 11 2012
I had created 2 trigger on Oracle 10gex to keep the records of users logon and logoff. here I am enclosing the codes:

CREATE TABLE "LOGON_AUDIT" ( "USER_ID" VARCHAR2(100), "SESS_ID" NUMBER(10,0), "LOGON_TIME" DATE, "LOGOFF_TIME" DATE, "HOST" VARCHAR2(100) )

create or replace trigger logon_audit_trig after logon on database begin insert into logon_audit values(user,sys_context('userenv','sessionid'), sysdate,null,sys_context('userenv','host')); end;

create or replace trigger logoff_audit_trig before logoff on database begin update logon_audit set logoff_time=sysdate where user_id=user and sess_id=sys_context('userenv','sessionid'); end;

well its working fine when user is properly logon and logoff (they fires connection open and connection close through asp.net pages) but it fails when the user close the browser without proper logoff or when the asp.net page session expires.

Even I calling connection close statement in global.asax under Session_End, code given below:

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a session ends.
' Note: The Session_End event is raised only when the sessionstate mode
' is set to InProc in the Web.config file. If session mode is set to StateServer
' or SQLServer, the event is not raised.
Dim cnn As New Connection
cnn.setConnection(System.Web.HttpContext.Current.Session("connection"))
cnn.close()
System.Web.HttpContext.Current.Session.Abandon()
System.Web.HttpContext.Current.Session("connection") = Nothing
System.Web.HttpContext.Current.Session("user") = Nothing
End Sub

but it still not firing the logoff trigger.

plz, give your best suggestion.

thnking you in advance and awaiting for your early response.

Regards,

M.A.Bamboat
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 8 2012
Added on Sep 21 2011
2 comments
447 views