# User login,logout and Session Info

**URL:** <https://forum.inductiveautomation.com/t/user-login-logout-and-session-info/41889>\
**Category:** Ignition\
**Tags:** vision, scripting, database\
**Created:** [January 1, 2021, 4:20pm UTC](https://forum.inductiveautomation.com/t/user-login-logout-and-session-info/41889 "2021-01-01T16:20:45Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 2, 2021, 4:01am UTC](https://forum.inductiveautomation.com/t/user-login-logout-and-session-info/41889/4 "2021-01-02T04:01:07Z")

</div>

Try something like this:

```auto
Select *, "NEXT_TSTAMP" - "EVENT_TIMESTAMP" As "DURATION"
From (
  Select *, lead("ACTION") OVER (Partition By "ACTOR" Order By "EVENT_TIMESTAMP") As "NEXT_TSTAMP"
  From audit_events
  Where .......
) subq
Where "ACTION"='login'
Order By EVENT_TIMESTAMP

```

The last login, if not yet logged out, will have nulls for NEXT\_TSTAMP and DURATION.

---

_[View the full topic](https://forum.inductiveautomation.com/t/user-login-logout-and-session-info/41889)._
