How to create a session variable in Django
August 3, 2016 · 2 mins read
This code stores the variable ‘name’ with a value ‘ranvirsingh’. Now whenever you want to show this code on the browser you need to ‘get’ this variable and then you can show on that page.
<code>var1 = "ranvirsingh" request.session['name'] = var1</code>
Now you can use the name ‘var1’ and show it wherever you want. That’s it for this post. If you have some questions then feel free to comment below.
<code>var1 = request.session.get('name') </code>
Please share your Feedback:
Did you enjoy reading or think it can be improved? Don’t forget to leave your thoughts in the comments section below! If you liked this article, please share it with your friends, and read a few more!