Using the CP login session expiration for the frontend I love the session handling on the backend CP. The prompts that come up on session expiration after setting 'userSessionDuration' =&gt; 'PT5M', in config/general.php are exactly what I want to use on the frontend website, (shown below). 



I would like to use this logic on the frontend to force session-ends after x minutes. Doing some digging I can see the logic lies in UserController under actionGetAuthTimeout(), and this is polled while I'm on the CP every minute. 
My question is whether I would have to manually run the controller constantly in the background and make the modal pop up? is there a more elegant method I've missed?

Thanks!
What you want is this:

// Returns how many seconds are left in the current user session.
// (int) The seconds left in the session, or -1 if their session
// will expire when their HTTP session ends.
craft()-&gt;userSession-&gt;getAuthTimeout()


You can then combine this with a Javascript setTimeout when the page loads so you can trigger whatever messages you need.

Edit: You can use this in your template files:

{% set authTimeout = craft.session.getAuthTimeout() %}