Last modified: Jan 10, 2023 By Alexander Williams
Checking if the Session exists in Django [Simple Method]
Today we'll learn how to check if a session is exists in django.
syntax
1 | if session_key in request.session: |
example:
So we have already a session, this session has 'test' as a key and we want to check if this session exists.
code:
1 2 | if 'test' in request.session: print('yes!') |
output
1 | yes! |