Challenge - 5 Problems
HTTPS and Secure Cookies Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
What does setting SECURE_SSL_REDIRECT = True do in Django?
In a Django project, what is the effect of setting
SECURE_SSL_REDIRECT = True in your settings.py file?Attempts:
2 left
💡 Hint
Think about what happens when a user tries to access your site with HTTP.
✗ Incorrect
Setting SECURE_SSL_REDIRECT = True tells Django to redirect all incoming HTTP requests to HTTPS, ensuring secure connections.
❓ component_behavior
intermediate2:00remaining
What happens if SESSION_COOKIE_SECURE is set to True?
In Django, if you set
SESSION_COOKIE_SECURE = True, what is the behavior of the session cookie?Attempts:
2 left
💡 Hint
Consider when cookies are sent by browsers based on security flags.
✗ Incorrect
When SESSION_COOKIE_SECURE is True, browsers send the session cookie only over HTTPS, protecting it from being sent over insecure HTTP.
📝 Syntax
advanced2:00remaining
Identify the correct way to set a secure cookie in a Django view
Which of the following Django view code snippets correctly sets a secure cookie named 'token' with value 'abc123'?
Attempts:
2 left
💡 Hint
Check the exact parameter names for set_cookie method.
✗ Incorrect
The set_cookie method uses secure and httponly (all lowercase) parameters to set cookie flags. Option C uses correct parameter names and values.
🔧 Debug
advanced2:00remaining
Why is the secure cookie not sent over HTTPS?
A developer sets
SESSION_COOKIE_SECURE = True in Django settings but notices the session cookie is not sent in HTTPS requests. What is the most likely cause?Attempts:
2 left
💡 Hint
Think about when secure cookies are sent by browsers.
✗ Incorrect
Secure cookies are only sent over HTTPS connections. If the site is accessed via HTTP, the cookie will not be sent.
❓ state_output
expert2:00remaining
What is the value of CSRF_COOKIE_SECURE after this settings change?
Given the following Django settings snippet, what is the value of
CSRF_COOKIE_SECURE after execution?
CSRF_COOKIE_SECURE = False
if DEBUG is False:
CSRF_COOKIE_SECURE = True
else:
CSRF_COOKIE_SECURE = False
DEBUG = FalseDjango
DEBUG = False CSRF_COOKIE_SECURE = False if DEBUG is False: CSRF_COOKIE_SECURE = True else: CSRF_COOKIE_SECURE = False
Attempts:
2 left
💡 Hint
Check the order of variable assignments and usage.
✗ Incorrect
The variable DEBUG is used before it is assigned, causing a NameError.