Concept Flow - HTTPS and secure cookies
User sends HTTP request
Server checks if HTTPS
No
Redirect to HTTPS URL
User sends HTTPS request
Server sets secure cookie with Secure flag
Browser stores cookie only on HTTPS
Subsequent requests send secure cookie only over HTTPS
Server reads secure cookie safely
This flow shows how a user is redirected to HTTPS and how the server sets cookies with the Secure flag so browsers only send them over HTTPS.