In session-based authentication, cookies store session IDs. Why does this method improve security compared to storing user data directly in cookies?
Think about where sensitive data is kept and what cookies actually contain.
Session cookies store only a session ID, not user data. The server keeps the sensitive info. This limits what an attacker can steal if they get the cookie.
In a Remix app using session-based auth, what is the expected behavior if the browser sends a request without the session cookie?
Consider what the session cookie represents and what happens if it is missing.
Without the session cookie, the server cannot identify the user, so it treats them as unauthenticated and usually redirects to login.
Which code snippet correctly sets a secure, HTTP-only session cookie in a Remix loader?
import { createCookieSessionStorage } from '@remix-run/node'; const sessionStorage = createCookieSessionStorage({ cookie: { name: '__session', httpOnly: true, secure: true, sameSite: 'lax', path: '/', maxAge: 60 * 60 * 24, }, });
Look for the option that sets httpOnly and secure flags correctly and uses a reasonable maxAge.
Option C sets httpOnly and secure to true, uses 'lax' for sameSite to balance security and usability, and sets maxAge to 86400 seconds (1 day), which is standard.
After successful login, the session cookie is not saved in the browser, causing the user to be logged out on refresh. What is the most likely cause?
Think about how the 'secure' flag affects cookie acceptance on HTTP vs HTTPS.
If 'secure' is true, cookies are only sent over HTTPS. On HTTP, the browser refuses to save the cookie, causing session loss.
In a Remix app using session-based auth, two concurrent requests modify the session: one adds a key 'a' with value 1, the other adds key 'b' with value 2. What is the final session state after both complete?
Consider how session storage handles concurrent writes and overwrites.
Session storage typically overwrites the entire session on save. Concurrent requests can overwrite each other's changes, so only the last write persists.
