Dear Tom
Thanks for your comment.
My use case is a "presence"-type system. When a user logs out their
status change is sent out to all other logged-in users (using comet).
If they just close the browser this doesn't happen. I'm mulling over
two possible solutions:
(a) some bit of javascript that will logout the user if they close the
browser or navigate away from the site (but I don't know if you can do
the former with js; and the latter to work properly if they have other
tabs still on the site). It requires javascript, but it's a fairly
javascript-heavy site anyway.
(b) something using SESSION_COOKIE_AGE. Set it to a few minutes and
have something running that will logout any users with expired
sessions (and delete the session too). Unfortunately the javascript
GET requests for the comet don't go through django, so they won't keep
the session alive. Setting SESSION_COOKIE_AGE too low will risk
logging out against users' wishes, but setting it to much more than a
few minutes will render this solution useless. This solution doesn't
feel right at all.
If (a) is possible I think I'll go with that.
Best
Ivan
You can't stop the user from closing the browser, or switching to another tab, with JS. And you shouldn't try to stop them navigating away - this sort of thing is only likely to annoy them intensely.
Instead, the best alternative that I've seen proposed is some sort of regular 'ping' - as long as the user has the page open, some Javascript contacts your server every minute or so, to let it know they're still there. Then you know that your 'active' users are those who have pinged in the last minute.
--
DR.
-- You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment