I was viewing the doc of Session in django, but don’t quite understand the meaning of the following:
Calling save() on a new session may also work but has a small chance of generating a session_key that collides with an existing one. create() calls save() and loops until an unused session_key is generated
What is the meaning of the first sentence? Is that a reminder that a session should call create() before save() ? Does it mean the following code hay have chance of session_key collision:
s = SessionStore()
s["name"] = "abc"
s.save()
? (or when would session_key collision may occur actually according to the first sentence from the doc of Session?)
Is the following code correct to avoid session_key collision?
s = SessionStore()
s["name"] = "abc"
s["age"] = 30
.
.
.
s.create()
s.save()