Basically, what I'm looking for is the Django/Python equivalent to the PHP
session_start(); print_R($_SESSION); That is, I'd like to dump all the information I currently have stored in the session so I can see what's in there.
The session is a dict-like object so you can simply print request.session to see what's in it.
The output will show up on the console of the server when using the development server - usually that's actually much better than print_r in PHP which dumps it to the webbrowser, next to whatever HTML you might have.
However, you could also return HttpResponse(repr(request.session)) if you do want to send it to the browser.
django-admin runserver during development. Anything you print in Python will show up there since print goes straight to stdout.docker exec.Since Django middleware stores all session data in request, we can access the session data in any view.As session is just a python dictionary(key,value pair),all the data can be accessed just like a normal python dictionary.
To store the data in session just do:
request.session['USER_NAME'] = 'John' Similarly, You can access it anywhere you have request object:
request.session.get('USER_NAME') So,To see the actual dictionary you can either print or log:
request.session