Engineering Decisions · Middle · Question 10 of 14

A web app talks to its own API on the same domain. Support must be able to end a stolen session immediately. How do you handle sessions?

Show the answer

Correct answer: Server sessions with an HttpOnly cookie

Explanation

With sessions on the server, deleting the record ends access at once, and an HttpOnly cookie stays out of reach of scripts. JWTs in localStorage fit almost nothing here: an XSS bug can read them, and they can't be revoked. Short-lived JWTs fit many independent services that verify tokens on their own, but a stolen token stays valid until it expires, unless you add a revocation list.

Further reading

Problem with a question

Engineering Decisions · Middle · question 10

Test yourself

Take the Engineering Decisions · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz