CppLearner
CppLearner

Reputation: 17040

How do I save a cookie throughout a session?

Suppose my django project gets some cookies from a server application (the webclient itself still gets django generated cookies). When I login django website, I ask for a cookie from that server application. It is currently saved in database, but we don't want this method.

My question is: does saving this cookie in request.session['special_cookies'] safe? How long does this information last?

What is a better way to save this information throughout browsing? Thanks.

Upvotes: 0

Views: 295

Answers (1)

Elf Sternberg
Elf Sternberg

Reputation: 16361

Yes, that's safe. It's still a database hit, though: in the standard Django configuration, session data is pickled into a binary data field in the session. It's just provided for you "out of the box" rather than your having to store it yourself. You can improve performance by using the cached_db setting and giving memecache a lot of the details.

RTFM, please.

Upvotes: 1

Related Questions