Helpful session tip

41 views
Skip to first unread message

Shannon Cruey

unread,
Jul 20, 2012, 2:37:21 PM7/20/12
to we...@googlegroups.com
Hey everyone, I spent about an hour on this so here it is if anyone ever gets stuck like I did.

I turned up my second web.py app today, and noticed I wasn't able to log in to both sites from the same browser.  You guessed it - session cookie conflicts.

After digging in I discovered by default the cookie_name for any web.py app is hardcoded.  I didn't find anything in the docs about how to change it, so I dug in to the code.  Here's the answer that worked for me...

    app = web.application(urls, globals(), autoreload=True)
    web.config.session_parameters["cookie_name"] = "my_app_name"
    session = web.session.Session(app, web.session.ShelfStore(shelve.open('session.shelf')))

This would be a perfect entry for the web.py wiki!  Coming soon???? :-P

S
Reply all
Reply to author
Forward
0 new messages