03 / Web / 30 min READ + PRACTICE
Cookies, sessions and authentication.
Understand session state, secure cookie attributes and defensive testing with dummy accounts.
Keep the identity on the server
A session cookie typically carries a random identifier, not a trusted role declaration. On successful login, rotate the identifier and store permissions server-side. Use HTTPS, HttpOnly and Secure attributes; choose SameSite deliberately for the application workflow.
Test with two dummy users
Create two accounts in your own practice app. Confirm an unauthenticated request cannot access a private page, logout invalidates the session, and one account cannot open another account’s data. Log only pass/fail evidence, not passwords or cookie values.
Discuss failure modes
Brute force, session fixation, insecure direct object references and CSRF are different classes of issues. Map each to a prevention: rate limiting, identifier rotation, object-level authorization and CSRF protections. Test only within your own scoped lab.
Try it in your lab
Write four acceptance tests for login, logout, expired session and cross-account access in a test app you own.
Make sure it clicks
Why does hiding a button in the frontend not enforce authorization?
A prompt you can adapt
Review my local session middleware and suggest tests for logout, session rotation and object-level authorization using dummy users.How to set up OpenCode ↗