On Apr 6, 2009, at 6:39 AM, edgarsmolow wrote:

if 'session-id' in session:
 ## do something
else:
 session['session_id'] = some_session_id
 session.save()
 ## do other stuff

When first coming to a web page, a new cookie is *always* being
created because the IF test *always* fails because the session id is
not found.  I was hoping that it would be found; that way, previously
entered data can be recouped.

Perhaps I am just not understanding the cookie mechanism.

I think that is part of the problem. Why would the session have data for a key that hasn't been set yet? There is only one key that exists by default in a brand new cookie-based session, and that is the session['_id'] field, also accessible as session.id. Nothing else will be found in a new session, so the behavior you report is the correct behavior.

Once you have saved the cookie-based session, two other attributes are added, session['_accessed_time'] and session['_creation_time'], since the session needs to have existed for those to be set.

Why would you expect it to have previous data if its the first time the user has ever come to the site?

Cheers,
Ben

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to