Jeff Atwood made an interesting comment on his blog, Coding Horror, about how to take advantage of AJAX to send sort-of heartbeat back to the server to keep the session from expiring. I think this is a great idea. Getting automatically logged out is extremely annoying (unless of course it’s my bank in which case I’m appreciative).

From his post:

As a user, I can say pretty unequivocally that session expiration sucks. Is it really so unreasonable to start doing something in your web browser, walk away for an hour — maybe even for a few hours — then come back and expect things to just work?

As programmers, I think we can do better. It is possible. I am inundated with session timeout messages every day from a variety of sources, but I’ve never once seen a session expiration message from gmail, for example. Here’s what I suggest:

Create a background JavaScript process in the browser that sends regular heartbeats to the server. Regenerate a new cookie with timed expiration, say, every 5 or 10 minutes.

Continue reading ‘Your Session Has Timed Out’…