Bird
0
0

After running manage.py check --deploy, you see a warning about SESSION_COOKIE_SECURE. What should you do to fix it?

medium📝 Debug Q7 of 15
Django - Security Best Practices
After running manage.py check --deploy, you see a warning about SESSION_COOKIE_SECURE. What should you do to fix it?
ASet <code>SESSION_COOKIE_SECURE = True</code> in settings.py
BSet <code>SESSION_COOKIE_SECURE = False</code> in settings.py
CRemove the <code>SESSION_COOKIE_SECURE</code> setting
DSet <code>SESSION_COOKIE_HTTPONLY = False</code>
Step-by-Step Solution
Solution:
  1. Step 1: Understand the warning meaning

    SESSION_COOKIE_SECURE ensures cookies are only sent over HTTPS, improving security.
  2. Step 2: Apply the correct fix

    Setting it to True enables this protection; False or removing it disables it and triggers warnings.
  3. Final Answer:

    Set SESSION_COOKIE_SECURE = True in settings.py -> Option A
  4. Quick Check:

    Enable secure cookies = A [OK]
Quick Trick: Always enable SESSION_COOKIE_SECURE in production [OK]
Common Mistakes:
MISTAKES
  • Disabling secure cookie flag
  • Removing the setting instead of fixing
  • Confusing with HTTPOnly flag

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes