Reputation: 211
I have mini content management sytem with basic login system. I wonder, how to prevent session expiration if user active for ex. typing content or something else? Is there any way to do it? How can i rearm the session every time an interaction takes place?
Upvotes: 1
Views: 1592
Reputation: 9549
Have an event listener listen to any user interaction event and have it call a simple PHP page with a session activity [Example: session_start()
].
But be extra cautious when listening to mousemove event, as it may choke your server by giving a lot of consequent AJAX requests. You could attach a timer and control the frequency of calls made.
Upvotes: 1
Reputation: 6522
You would need to attach an event handler to some user interaction event, such as mouse movement, or keyup, or something similar. On the event you could request something from the server using ajax. This would then keep the session alive.
Upvotes: 1