# How to track perspective sessions from my Perspective module

**URL:** <https://forum.inductiveautomation.com/t/how-to-track-perspective-sessions-from-my-perspective-module/30724>\
**Category:** Module Development\
**Tags:** ignition80\
**Created:** [December 16, 2019, 7:47am UTC](https://forum.inductiveautomation.com/t/how-to-track-perspective-sessions-from-my-perspective-module/30724 "2019-12-16T07:47:53Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Yogini\_Marathe](https://avatars.discourse-cdn.com/v4/letter/y/85e7bf/32.png) [@Yogini\_Marathe](https://forum.inductiveautomation.com/u/Yogini_Marathe)\
**Post date:** [December 17, 2019, 6:07am UTC](https://forum.inductiveautomation.com/t/how-to-track-perspective-sessions-from-my-perspective-module/30724/5 "2019-12-17T06:07:13Z")

</div>

Thank you for letting us know the way to subscribe to perspective session events.  
I was able to use PerspectiveContext.get() and subscribe to the Perspective session listener.

Following is the code in gateway hook startup:

```auto
this.perspectiveContext = PerspectiveContext.get(this.gatewayContext);
this.perspectiveContext.getEventBus().register(new PerspectiveSessionListener());

```

And below is listener class to handle the session events.

```auto
import com.google.common.eventbus.Subscribe;
import com.inductiveautomation.perspective.gateway.event.SessionShutdownEvent;
import com.inductiveautomation.perspective.gateway.event.SessionStartupEvent;
public class PerspectiveSessionListener {
	
	@Subscribe
	public void sessionStarted(SessionStartupEvent startupEvent)
	{
        	//do session start event handling. All session props are available here.
	}
	
	@Subscribe
	public void sessionEnded(SessionShutdownEvent shutdownEvent)
	{
		//do session end event handling
	}
	
}

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/how-to-track-perspective-sessions-from-my-perspective-module/30724)._
