I have a list of “online users”, which I refresh every 30 seconds with Ajax.PeriodicalUpdater from prototype.js.
There is an issue, that if a user has two tabs/windows open with the site, logs out in one of them, the PeriodicalUpdater is not canceled.
This means that PeriodicalUpdater updates my block element with the entire login page, as I have a restful authentication, that redirects to that.
I am using PHP sessions, and I really cannot get my head straight on this one.
Can any of you guys point me in the right direction?
I would consider changing the method that returns the results so that it doesn’t require an authenticated session to access it, but it returns valid information only when there is an authenticated session. Otherwise, it returns a value indicating that the updates should cease and a suitable message for display in your online user’s block. This would mean that you’d probably need to return JSON instead — not a bad thing — and either combine it with an HTML snippet as part of the JSON or simply construct the HTML on the client from the JSON data (better IMO since the view is the correct place to do mark up).