I'm aware that you can get session variables using request.session['variable_name']
, but there doesn't seem to be a way to grab the session id as a variable in a similar way. Is this documented anywhere? I can't find it.
session_data : Django stores the session data in the encoded format. To get the raw data, use the get_decoded() method of the session object.
The SessionID property is used to uniquely identify a browser with session data on the server. The SessionID value is randomly generated by ASP.NET and stored in a non-expiring session cookie in the browser. The SessionID value is then sent in a cookie with each request to the ASP.NET application.
The session ID can be defined by a command line option or a resource. The session ID can be a single value; for example “Smith". A set of session Ids can be defined; for example, Smith+n where n is 3 would make 3 session Ids available, “Smith1", “Smith2", and “Smith3". Each 5250 session has a unique session ID.
request.session.session_key
Note the key will only exist if there is a session, no key, no session. You can use this to test if a session exists. If you want to create a session, call create.
Django sessions save their key in a cookie. At least its middleware extracts it like this:
from django.conf import settings session_key = request.COOKIES[settings.SESSION_COOKIE_NAME]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With