11👍
In a past project I did what you are suggesting but just within a view where I needed to use session_key
for unauthenticated visitors. It did not cause any problems in my project:
if not request.session or not request.session.session_key:
request.session.save()
# request.session.session_key now set
-4👍
You can choose to save session every request by setting:
SESSION_SAVE_EVERY_REQUEST = True
This force django to assign the session key for each session
https://docs.djangoproject.com/en/2.1/topics/http/sessions/#when-sessions-are-saved
- Django Celery send register email do not work
- Secure static media access in a Django site
- Can I get expiration time of specified key in django cache?
- Django Serializer Nested Creation: How to avoid N+1 queries on relations
- Django 1.6 and django-registration: built-in authentication views not picked up
Source:stackexchange.com