# 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:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shanmukharao.C](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/shanmukharao.c/32/29664_2.png) [@Shanmukharao.C](https://forum.inductiveautomation.com/u/Shanmukharao.C)\
**Post date:** [January 1, 2021, 4:20pm UTC](https://forum.inductiveautomation.com/t/user-login-logout-and-session-info/41889/1 "2021-01-01T16:20:45Z")

</div>

Hello,  
i am able to fetch the active users info by system.util.getSessionInfo(),  
I Created Audit Profile in my project, Below Query :Select “EVENT\_TIMESTAMP”,“ACTOR”,“ACTION” from audit\_events where “ACTOR” = ‘Shanmukha’ and “ACTION” like ‘log%’ . i am Fetching the User LOG Details in a Single column but  
I would like to see the Specific Users Login, Logout, Session Time with respect to Time in individual columns respective table.  
please help me on this.  
Thank you.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/9/290d40b0ed6e5f31ac3b8dcb7f7deaf26c282156.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/1/41ba76bd562a329da47fb64072026c0ad291f950.png)

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [January 1, 2021, 7:28pm UTC](https://forum.inductiveautomation.com/t/user-login-logout-and-session-info/41889/2 "2021-01-01T19:28:58Z")

</div>

What sql database are you using, and what version?

Try the answer in the OP from here: [https://stackoverflow.com/questions/42655443/login-logout-time-in-sql-server](https://stackoverflow.com/questions/42655443/login-logout-time-in-sql-server)

---

<div class="post-metadata">

**Author:** ![Shanmukharao.C](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/shanmukharao.c/32/29664_2.png) [@Shanmukharao.C](https://forum.inductiveautomation.com/u/Shanmukharao.C)\
**Post date:** [January 2, 2021, 3:28am UTC](https://forum.inductiveautomation.com/t/user-login-logout-and-session-info/41889/3 "2021-01-02T03:28:49Z")

</div>

Hi Nminchin,  
i am using  
Database:PostgreSQL 10.10 on x86\_64-pc-linux-gnu and Ignition Version: 8.0.15

---

<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.
