A session cookie is a temporary cookie that is stored in the user’s browser only for the duration of a single browsing session and deleted when all browser windows are closed.
Typical use cases for using a session cookie include:
- User authentication. Once a user logs in, you want them to stay logged in until they close their browser.
- Save session state for things like remembering items in a shopping cart or user inputs on a multi-page form.
- Save user preferences (e.g., layout of products on an e-commerce site).
Most web application frameworks like Rails, Symfony, Laravel, or Django automatically setup session cookies to make it easier for you to manage user-specific state.