﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
26503	SessionStore nonexistent key example is outdated	jmcbailey	Berker Peksag	"The documentation at https://docs.djangoproject.com/en/1.8/topics/http/sessions/#using-sessions-out-of-views has the following example:

{{{#!python
from django.contrib.sessions.backends.db import SessionStore
s = SessionStore(session_key='no-such-session-here')
s.save()
s.session_key
'ff882814010ccbc3c870523934fee5a2'
}}}

However, when I run this with Django 1.8.12, {{{s.session_key}}} actually returns {{{None}}}.

The reason is that when the {{{SessionStore}}} instance is saved (with {{{must_create=False}}}, i.e. the default), it results in a call to {{{self.load()}}}, which looks for an existing Session object with the given session_key. This of course does not yet exist, so the session_key gets set to {{{None}}} - see https://github.com/django/django/blob/1.8.12/django/contrib/sessions/backends/db.py#L29

I don't know if this change in behaviour was intentional or not, but I didn't see any mention of it in the 1.7 or 1.8 release notes, and of course the fact that the behaviour is different to what's documented suggests it was not intentional. (I haven't checked the file's history, but it definitely did work as documented in Django 1.6.)

In any case it's a pretty minor issue, only affecting one unit test of mine, and was very easy to work around."	Bug	closed	contrib.sessions	1.8	Normal	fixed		Carl Meyer berker.peksag@…	Accepted	1	0	0	0	0	0
