Python Flask Basics Character Builder Cookies

Chris Fischer
Chris Fischer
1,476 Points

Why cookies instead of session variables?

My first instinct on a site like this would be to store user choices in a session variable. Is there any benefit to using cookies for this?

2 Answers

I think it comes down to the kind of data you're storing, and whether you want the client or the server to process it.

Here's an interesting Stack Overflow question that is similar: Why store sessions on the server instead of inside a cookie?

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Sessions are, by default, cleared once the browser is closed. By using a cookie, we're making sure the choices come back next time you play with the site.