Last modified: Jan 10, 2023 By Alexander Williams
Creating and getting a session in Django
in this article, we will create a session in Django
so let's create a session
1.creating a session
syntax:
1 | request.session[ket] = value |
example:
1 | request.session['test'] = 'hello world' |
2.getting session
To get the session above we need to do something like this:
syntax:
1 | request.session.get(session key) |
example:
1 2 | my_session = request.session.get['test'] print(my_session) |
output:
1 | hello world |