Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.