x

How to implement audit trail for session log??

I need to implement audit trail for following


sessionId
UserId
DisplayName
LoginTime
LogOutTime
SessionDuration
more ▼

asked Nov 09 '09 at 06:56 AM in Default

savibp gravatar image

savibp
52 5 6 8

(comments are locked)
10|1200 characters needed characters left

2 answers: sort newest
I need to do the same but cannot find a solution to this paradigm. Someone please help!
more ▼

answered Oct 18 '11 at 03:51 AM

JWDBA gravatar image

JWDBA
1

(comments are locked)
10|1200 characters needed characters left

Insert a row in the Audit Trail table when they log on. Store the ID of that in the user's Session. Update the row, using the ID stored in the Session, when they LogOff.

If they do NOT logoff its a bit more tricky - their session will, presumably, expire of its own accord XXX minutes after last activity.

You could record a "most recent activity" column too, so each time they do something you upload the Date/Time in that column; then if they don't logoff the LogOutTime will be NULL, but you will have the "most recent activity" time instead.

more ▼

answered Nov 09 '09 at 08:33 AM

Kristen gravatar image

Kristen ♦
2.2k 6 7 10

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1816
x81
x42

asked: Nov 09 '09 at 06:56 AM

Seen: 1573 times

Last Updated: Nov 09 '09 at 08:35 AM