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 trialChris Fischer
1,476 PointsWhy 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
Iain Simmons
Treehouse Moderator 32,305 PointsI 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
Treehouse Guest TeacherSessions 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.