question

savibp avatar image
savibp asked

How to implement audit trail for session log??

I need to implement audit trail for following

                    
sessionId                    
UserId                    
DisplayName                    
LoginTime                    
LogOutTime                    
SessionDuration                    
sql-server-2008loginaudit
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kristen avatar image
Kristen answered

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.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

JWDBA avatar image
JWDBA answered
I need to do the same but cannot find a solution to this paradigm. Someone please help!
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.