Sessions and Cookies, and When They Fit Better

A session signs a user in with a random id from secrets.token_urlsafe, kept in a sessions table and sent in an HttpOnly, Secure, SameSite cookie, so signing out deletes a row and takes effect at once, which suits one website on one server better than a token that stays valid until it expires.

By

Updated

Cheat sheet: Sessions and Cookies, and When They Fit Better
Category
FastAPI
Level
Journeyman
Tags
Cookie, fastapi, HttpOnly, rest-api, SameSite, Session (web-development), Stateless