[ic] Time Left In Session

Jon Jensen jon at endpointdev.com
Tue Feb 1 21:28:38 UTC 2022


Phil,

Sorry I missed this when you asked it.

What you want to do is possible but would be somewhat complicated, and I 
don't know of anyone having done this exact thing.

You could have your Ajax request hit a special Interchange ActionMap with 
?mv_tmp_session=1 appended, which prevents Interchange from automatically 
opening the session. Then your ActionMap can get the session ID from the 
session cookie and you can peek into the session to see its age by looking 
at the "time" element that is there by default in all file sessions.

I just pushed to the eg/ section of the Interchange codebase an example 
module that may be useful to you if you want to do something like that:

https://github.com/interchange/interchange/commit/7c67dc7ea86b5eca4b8aabb4bd72b0850504e839

Another way you could approach it would be not to involve Interchange 
directly at all. You could have JavaScript code in your front-end keep 
track of when the MV_SESSION_ID cookie is created by Interchange, and 
update a timestamp every time you talk to the backend and thus when you 
know the session is again active, and base your decisions on that.

That seems to me like it may be easier.

HTH,
Jon


On Wed, 13 Oct 2021, Phil Smith wrote:

> Hi All
>
> I'm after some advice, I would like to add a JQuery popup to my IC site
> warning users their session is about to expire. We have some JQuery pages
> that users can use for ages without actually submitting anything back to the
> server, so the IC session times out.
>
> I originally thought a simply ajax request every few minutes to check if the
> session is still logged in - then occurred to me, those requests alone will
> keep the session alive.
>
> Is there any way to see how long a session has been inactive, without
> effecting the session itself?
>
> I am using file based sessions, would rather not move the sessions into the
> DB, but could if that is the only way.
>
> Thanks in advance
>
> Phil.


-- 
Jon Jensen
End Point Corporation
https://www.endpointdev.com/


More information about the interchange-users mailing list