Thursday, December 17, 2009

Re: Logout and session

Okay, let me further explain my problem...

 My website depends heavilly on the caching system, I'm using cache_page to cache my view ( using memcached backend ),
however I have the "Hello, <logged in user>"  on top of every page when the user is logged, thus I cant just cache everything.
So I began experimenting with @vary_on_cookies decorator, which seems to solve my problem, I will be caching my views based on a computed hash of the available cookies on the client ( as a side note, I had to apply a patch to django, in order for it to ignore certain cookie name regexp's, so that my google analytics cookies are ignore when building the view cache key for example).
 That solved my problem, using @vary_on_cookie on my views, now I solved my caching issues, however I noticed that whenever a user logs out, I recieve a new sessionid, thus if the user log's in I will create a cache for him, based on its session id. But when it logs off, instead of joining the other clients that dont have the sessionid, it will become another "cached instance", and I have to avoid that situation.

 I would like to understand why does django sends me another cookie after I logout calling auth.logout ( request )? And how can I
disable that? Or maybe, someone can point to the right design pattern for this situation.

thanks,
Victor Lima

2009/12/17 David De La Harpe Golden <david.delaharpe.golden@ichec.ie>
Victor Loureiro Lima wrote:.

> auth system is in fact invalidating my current session id cookie, but
> afterwards it sets a new session id cookie, why does it do that?
>

Um. So that anonymous users of your site still have sessions? Django
supports "anonymous sessions", sessions and auth are different.

> Basically on my systems, I want to differentiate user in two groups:
> Anonymous ( ones that doesnt have a valid session id cookie ), logged ones (
> ones that have a valid session id cookie ).

That's just not the way that distinction is made. Seeing as sessions
may be anonymous and all.  For your code, note that if request.user is a
logged in User, .is_authenticated() will be True and .is_anonymous()
will be False.  OTO, if request.user is an AnonymousUser,
.is_anonymous() will be True and is_authenticated() will be False.






--

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.



--

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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate