home
Sumuditha Lansakara

How Websites Remember You: Cookies and Sessions Explained Simply ✨

Wed Mar 20 2024

Ever wondered how websites remember you ?

Ever logged in to a site and stayed logged in ? Or returned to an online shopping cart to find your items still waiting for you ? That's the magic of cookies and sessions.

What are cookies ? 🍪

Think of cookies as tiny text files that websites store on your device. They're like little reminder notes holding information such as login details, site preferences (like language), or items in your cart.

Why use cookies ? 🤔

Cookies offer convenience! They personalize your experience and save you time by remembering things you've done before. They're like your helpful sidekick making your online journey smoother.

What are sessions ? 🗣️

Imagine having a chat with a store assistant. The conversation (session) only lasts for your visit, but the assistant remembers details about your chat (like what you tried on) for that time. Sessions work similarly. They're temporary storage on the server side (where the website lives) that keep track of your activity during your visit. They can hold more data than cookies, like your entire shopping cart!

Why use sessions ? 🚀

Sessions are crucial for maintaining your progress across multiple pages on a website. They let you freely browse, add items to your cart, or explore different products without losing track of what you're doing. But just like your conversation with the store assistant ends when you leave, the session ends when you close your browser.

Relationship between Cookies and Sessions🍪🗣️

• Websites give you a secret ID (like a handshake) to remember your conversation (session).

• This ID is often stored in a cookie on your device.

• With each page visit, the cookie sends your ID back, reminding the website who you are and what you were looking at!

Basically,

• Cookies are reminders on your device.

• Sessions are conversations on the website's side.

• Together, they make browsing smoother!