A cookie is a small piece of data stored in a user's browser by a website. Cookies often store session data, user preferences, or tracking information.
Also known as: HTTP cookie, browser cookie.
Comparisons
- Session vs. Persistent Cookies: Session cookies expire when the browser closes, while persistent cookies remain until a set expiration date.
- First-party vs. Third-party Cookies: First-party cookies originate from the site being visited; third-party cookies come from external domains.
Pros
- Enhanced user experience: Stores preferences for faster and personalized interactions.
- Facilitates analytics: Tracks user activity for insights.
Cons
- Privacy concerns: Can be used for intrusive tracking.
- Storage limitations: Maximum size of 4KB per cookie.
Example
A cookie stores a user’s shopping cart items on an e-commerce website to retain the cart during the browsing session.