while the term โsessionโ is usually used for a server-side mechanism that naturally cannot be used without any server side script, you could implement a pseudo session in JS if you only want to have login tracking:
- implement a hidden field with user login timestamp as value
- update this field with a new timestamp every time the user takes a significant action.
- run the pseudo-cronjob with setinterval (), check if the value in the hidden field is older than your allowed session time
- if he is older, complete your session timeout
be careful, 1. such a mechanism can lead to some stress in the browsers of your clients depending on your site and parameters (observed actions, frequency of the test interval) 2. this will not be saved if the user closes the browser window / tab
source share