Logging a session-expired event

9 views
Skip to first unread message

Maor

unread,
Apr 19, 2012, 5:17:56 AM4/19/12
to PyWeb-IL
Hi all,

I'm using Django and I need to log the event of session-expired. What
I mean is that after 10 minutes of no activity by the user, I want to
expire the session and write to my logs that the user was "logged-out
due to inactivity".
For that I plan to write a daemon that goes over the sessions and
delete any session that is older than 10 minutes.
My questions:
1. Has anyone done something like this?
2. Any advice on how to iterate over the current sessions on the
Django server?
3. Any advice how to delete a session?
4. Any pitfalls that I should be careful about?

Thanks,
Maor

Yishai Beeri

unread,
Apr 19, 2012, 5:54:41 AM4/19/12
to pywe...@googlegroups.com
Hi,
Consider not deleting the sessions, but only actually expire them when you
get a new request with the (inactive) session. You can check this in a
middleware.

Yishai

On Thu, 19 Apr 2012 12:17:56 +0300, Maor <maor.c...@kaminario.com>
wrote:

Reply all
Reply to author
Forward
0 new messages