Performance: HTTPS and secure cookies
This concept affects page load security and user data protection, indirectly influencing user trust and interaction speed.
Jump into concepts and practice - no test required
response.set_cookie('sessionid', session_value, secure=True, httponly=True, samesite='Lax')
response.set_cookie('sessionid', session_value, secure=False, httponly=False)
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Insecure cookies over HTTP | 0 | 0 | 0 | [X] Bad |
| Secure cookies over HTTPS with HttpOnly and SameSite | 0 | 0 | 0 | [OK] Good |
SESSION_COOKIE_SECURE = True in Django settings?SESSION_COOKIE_SECURE doesSECURE_SSL_REDIRECT controls whether Django redirects HTTP requests to HTTPS.SECURE_SSL_REDIRECT = True enables automatic redirection to HTTPS. The other options either disable security or relate to cookies.SECURE_SSL_REDIRECT = True SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True
SECURE_SSL_REDIRECT = TrueSESSION_COOKIE_SECURE and CSRF_COOKIE_SECURE ensure cookies are only sent over HTTPS, but the redirect happens first.SESSION_COOKIE_SECURE = True but notice session cookies are still sent over HTTP. What is the most likely cause?SECURE_SSL_REDIRECTSECURE_SSL_REDIRECT is not enabled, users can access the site over HTTP, so cookies may be sent insecurely despite SESSION_COOKIE_SECURE.SECURE_SSL_REDIRECT = True forces all HTTP requests to HTTPS, preventing insecure access.SESSION_COOKIE_SECURE and CSRF_COOKIE_SECURE to True ensures cookies are only sent over HTTPS connections.