🔐Session/Cookie based Authorization
HTTP is a stateless protocol, meaning every request made to the server is independent the server doesn’t remember who sent it.
To overcome this, web applications use Session-Based Authorization to maintain a user’s state across multiple requests.
When a user logs in using their credentials, the server authenticates them and creates a session a small piece of stored information that represents the user’s state. The server then generates a unique Session ID, which is sent back to the client (usually stored inside a cookie 🍪).
From this point on, every request made by the client automatically includes the Session ID. The server uses this ID to look up the associated session details in its session log or memory, confirming that the user is already authenticated and authorized to access specific resources.
This process continues seamlessly, allowing the user to navigate the website or application without repeatedly entering their credentials. When the user logs out or the session expires, the Session ID is invalidated, ensuring that unauthorized access cannot occur.
In simple terms the session acts as a temporary bridge of trust between the client and the server, helping the system maintain identity across multiple stateless HTTP requests.
Session-based authorization remains one of the most common methods for maintaining secure user access in traditional web applications.
⚠️ Drawbacks of Session-Based Authorization with Load Balancers
⚠️ The Scalability Problem
Even though sticky sessions fix consistency, they introduce new limitations when scaling applications horizontally:
🧠 What is Shared Session Cache?
Instead of storing sessions locally on each server, all servers share one central session store (e.g., Redis).
So no matter which server the user’s request hits, that server can fetch the session data from the shared cache.
Workflow:
This approach removes the need for sticky sessions and supports true load balancing.
Recommended by LinkedIn
⚙️ Advantages
✅ No session loss — users can hit any server and still be authenticated. ✅ Better scalability — servers are stateless; you can add/remove them freely. ✅ Centralized management — all sessions in one place.
⚠️ But There Are Still Issues
Even though shared session cache solves the main scalability and consistency problems, it introduces new challenges:
In web security, there are three main mechanisms for maintaining user sessions:
1️⃣ Cookie-based Sessions – The browser stores a session ID (or token) in a cookie and sends it with every request.
✅ Simple and widely used ⚠️ Vulnerable to theft (XSS/CSRF) if not secured properly
2️⃣ Sticky Sessions – The load balancer “sticks” a user to the same server where their session was created.
✅ Easy to implement ⚠️ Scalability issues — if one server fails, all its sessions are lost
3️⃣ Shared Session Cache – Sessions are stored centrally (e.g., in Redis or Memcached), and any server can fetch them.
✅ Enables load balancing ⚠️ Adds infrastructure complexity and potential cache bottlenecks
🧠 When to Use What? It depends on your application architecture, traffic scale, and security requirements.
💡 In Software Security, there’s no silver bullet — every approach has trade-offs. The key is to understand your system’s needs and design for security, scalability, and reliability together.
#WebSecurity #SessionManagement #SoftwareArchitecture #Authentication #CyberSecurity #BackendDevelopment