On Sep 1, 2011, at 11:49 AM, Joe Barnhart wrote: > Cookies and session ids are a bit of "black magic" to me. I assume > that web2py handles the setting of the session cookie with the > associated session id when the page is rendered. But I have no idea > if this is right or not. It certainly is acting as though web2py is > being contacted without the session cookie and assigning a new one. > You may be on to something. > > From the jQuery article, I'm not sure how I'd find the original web2py > cookie and pass it back using my ajax request. Maybe I would just > need to create my own and use it instead of web2py's? But then lose > the nice automatic session state things web2py does for me. (After > all, I use web2py because I'm LAZY!)
I hope someone who has more experience on the Ajax side will chime in here. The cookie name is 'session_id_%s' % appname, so you'd want that cookie from the current document. > > -- Joe B. > > On Sep 1, 11:38 am, Jonathan Lundell <[email protected]> wrote: >> On Sep 1, 2011, at 11:25 AM, Joe Barnhart wrote: >> >>> Update -- >> >>> This problem is variable. After logging into the admin session, >>> logging out, closing the browser, and then opening it again the >>> website seems to add sessions for me even as an unauthenticated user. >>> Even after opening up a different browser it continued to work. But >>> when someone else tries it from a different computer, no session id is >>> generated and no session information is retained. >> >>> I have also tried storing session information in the database with no >>> difference. >> >> Is it possible that the variability you're seeing is caused by your Ajax >> requests not setting the web2py session cookie? >> >> http://webhole.net/2010/07/10/jquery-cookies-example/ >> >> (I don't really know what I'm talking about here, so maybe this is handled >> elsewhere in the web2py Ajax logic. But the main reason that web2py >> generates a new session id is that the request doesn't have a session >> cookie.)

