Get SESSION id/key (session_key)

Posted: June 23rd, 2010 | Author: Davo | Filed under: Django | Tags: | 4 Comments »

You can easily grab the session key/id from the request object

     print request.session.session_key

4 Comments on “Get SESSION id/key (session_key)”

  1. 1 igor ganapolsky said at 7:18 pm on June 23rd, 2010:

    Very concise and useful.

  2. 2 Tim Fletcher said at 2:43 am on June 30th, 2010:

    Can you give a quick example of an application of this? Why might I want to know the session key?

  3. 3 Arif Harbott said at 4:32 pm on July 3rd, 2010:

    Sure. One user case could be in a shopping cart when a user has not logged in we store the session id as the key to identify that specific user.

  4. 4 Tim Fletcher said at 1:13 am on July 5th, 2010:

    Ahhh… Thanks!


Leave a Reply