Which Django setting forces all cookies to be sent only over HTTPS?
easy📝 Conceptual Q2 of 15
Django - Security Best Practices
Which Django setting forces all cookies to be sent only over HTTPS?
ASECURE_SSL_REDIRECT = True
BSECURE_HSTS_SECONDS = 0
CCSRF_COOKIE_HTTPONLY = True
DSESSION_COOKIE_SECURE = True
Step-by-Step Solution
Solution:
Step 1: Identify cookie security settings
SESSION_COOKIE_SECURE ensures session cookies are sent only over HTTPS.
Step 2: Differentiate from other settings
SECURE_SSL_REDIRECT redirects HTTP to HTTPS but does not affect cookie flags. CSRF_COOKIE_HTTPONLY controls JavaScript access, and SECURE_HSTS_SECONDS sets HTTP Strict Transport Security duration.