How Cookies and Login Sessions Work Together

You open your bank’s website, type your password once, and then browse through your account, check your balance, and download a statement without logging in again. But have you ever wondered how the website remembers you from one page to the next? The answer lies in two things working quietly in the background: cookies and login sessions.
Why Websites Need a Memory at All
The web runs on a system called HTTP, which is stateless by design. That means every time your browser sends a request to a website, the website has no built-in way to know who you are. It treats each request as if it came from a complete stranger. This was fine in the early days of the internet, but once websites started handling logins, shopping carts, and personal accounts, a memory system became necessary.
Cookies were introduced back in 1994 to solve exactly this problem. A cookie is a small piece of text no larger than 4 KB that a website saves on your device through your browser. Sessions, on the other hand, are records the website keeps on its own server. The two work together like a locker and a key. Your browser holds the key the cookie, and the server holds the locker the session data.
How a Login Actually Works Step by Step
When you log in to a website, here is what happens in order:
- You enter your username and password and click Login.
- The website’s server checks your credentials against its database.
- If they match, the server creates a session, which is a temporary record saying “this user is verified.” It gives that session a unique ID, something like a long random string of letters and numbers.
- The server sends that session ID to your browser as a cookie.
- Your browser stores that cookie and sends it back automatically with every request you make on that site.
- The server reads the session ID from the cookie, matches it to its records, and serves you your personal data.
This is why you don’t have to log in again every time you click a new page. The cookie carries your session ID silently in the background.
Session Cookies vs Persistent Cookies

Not all cookies behave the same way. Understanding the difference helps you manage your privacy better.
| Type | How long it lasts | Common use |
|---|---|---|
| Session cookie | Deleted when you close the browser | Temporary login, shopping cart |
| Persistent cookie | Stays for a set time (days, months) | Remember me feature, preferences |
| Third-party cookie | Set by a different site (usually ads) | Tracking across websites |
When you tick Remember me on a site like Myntra or Swiggy, the site sets a persistent cookie with a longer expiry. Next time you open the browser, your session is restored automatically. Without that tick, a session cookie is used, and you have to log in again after closing the tab.
What This Means for Indian Users in Real Life
Think about IRCTC. You log in, search for trains, and then go to your booking history, all within the same visit. A session cookie keeps you connected throughout. If IRCTC used no cookies at all, you would have to enter your credentials on every single page.
The same logic applies to your net banking portal, your OTT subscriptions like Hotstar or JioCinema, and even government portals like DigiLocker. For cricket enthusiasts using sports platforms, this also applies to services like lotus365 cricket, where your preferences and account state are maintained using the same cookie-session system.
India now has over 820 million internet users TRAI, 2024, and most of them interact with cookie-based systems every day without realising it.
What Happens When You Clear Your Cookies
Clearing cookies removes all those stored session IDs from your browser. The result is immediate. You get logged out of every website where you were previously signed in. This is because the server can no longer match your request to any active session.
This is also why shared computers in cybercafes or libraries in cities like Pune or Hyderabad are risky for logging in. If you forget to log out, the next person to use that machine can simply open the same browser and find your session still active. Clearing cookies before leaving is one simple way to protect yourself.
Security Risks You Should Know About

Cookies are generally safe, but they can be misused. Session hijacking is a real threat listed by OWASP as one of the top web security risks. If someone intercepts your session cookie usually over an unsecured Wi-Fi connection, they can use it to access your account without knowing your password at all.
Reputable websites protect against this in several ways. They mark cookies as Secure sent only over HTTPS and HttpOnly not accessible by JavaScript. They also set short expiry times for session cookies. Platforms like lotus365 red and other online platforms follow similar practices to keep session data protected.
Under India’s Digital Personal Data Protection Act 2023, websites that collect user data through cookies are required to inform users and obtain consent. So if you see a cookie consent banner on an Indian website, that is not just a technicality. It is a legal requirement.
Do Cookies Store Your Password?
No. This is one of the most common misunderstandings. Cookies store a session ID, not your actual password. Your password is verified once at login and never saved in a cookie. The session ID is a random code that only means something to the server that created it. Even if someone copied that cookie file from your device, they would not see your password.
