Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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.