Thursday, September 29, 2011

set_test_cookie() on every page?

Hi,

I've read the Django docs on setting test cookies (https://docs.djangoproject.com/en/dev/topics/http/sessions/#setting-test-cookies), and I'm still a bit confused.

One of our views sets a session variable to remember the object a user is currently viewing (we figured it wasn't worth storing in the database for this).

Should I put set_test_cookie() on every view? That seems a bit silly/redundant.

However, if I only put it on the view that sets the session variable, doesn't that mean the user has to visit that page twice - once to set the cookie, and (since the if test will fail that first time) again to verify it was set? How will the user even know to do that?

Do people actually check for the test cookie these days, or do they just assume it's set?

But then if we call delete_test_cookie(), doesn't that mean we have to set it all over again if the user needs to sets thesession variable again? Or should we not call delete_test_cookie()

Cheers,
Victor

--
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/-/VZwP7behBtAJ.
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