If I understand correctly, you just need to set
SESSION_EXPIRE_AT_BROWSER_CLOSE = True in your settings:
https://docs.djangoproject.com/en/1.4/topics/http/sessions/#browser-length-sessions-vs-persistent-sessions

When the user closes their browser, the session ends. True, the
associated data isn't deleted right when this happens (the server has no
way of knowing when the user has done this), but that data will no
longer be associated with anyone. If you're particularly concerned about
the data not going to disk, you can use a cached session engine (with
memcached) , as Javier suggests:
https://docs.djangoproject.com/en/1.4/topics/http/sessions/#using-cached-sessions

It may help to know a little bit more about what you're trying to
accomplish. Is your concern security or user experience related?

_Nik

On 1/19/2013 12:03 PM, testbackupa...@gmail.com wrote:
> Hi,
>
> I've got some data that I'll need read/write access to for the length
> of an authenticated session's lifetime. But once that browser tab is
> closed or the user logs out or the user session times out, I want that
> data to disappear.
>
> If I'm reading the session docs correctly, if I add the data to the
> session object, it'll get persisted, which I don't want. I believe
> I'll have the same problem if I extend the user profile. And I
> *really* don't want to store the data in the session cookie.
>
> For the time being, I'm just storing it in a global data structure in
> my views.py, and deleting the data via a 'user logged out' signal. But
> I can't seem to find a 'session timed out' signal to catch. And,
> anyway, I can't shake the feeling that there's a better way to do
> this. Is there?
>
> Thanks in advance!
>
> Spork
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/dokMLZNlkbIJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to