Hello all, I'm sure I'm not using this right, but I don't understand what I'm doing wrong. What I want is to get all the cookies from the request, then extract the 'sessId' cookie. I'm using this code:
----------------- from mod_python import Cookie [---] def index(req, sessId = None): cookies = Cookie.get_cookies(req) if not sessId and cookies.has_key('sessId'): sessId = cookies['sessId'] sess = Session(req, sessId) httphdr(req) ----------------- (Note: The Session() constructor will attempt to set the cookie, and httphdr() is responsible for the send_http_header() call). This is the part I don't understand. If the sessId cookie exists, it will fail because the returned sessId object will be a Cookie object. If I print str(sessId), I will get the output "sessId=blah". The cookie is set using: c = Cookie.Cookie('sessId', 'blah') c.expires = time.time() + 60*30 Cookie.add_cookie(req, c) So, the part I don't understand is why sessId = cookies['sessId'] ... is returning a Cookie-object. I would have expected to get a string containing "blah"? I can get this to work, by doing this: cookies = Cookie.get_cookies(req) c = str(cookies['sessId']).split('=', 1) ...then use c[1]. Is that the proper way? Seems kind of strange to store the cookies in a dictonary without being able to use the benefits of them? -- Kind regards, Jan Danielsson ------------ And now a word from our sponsor ------------------ Want to have instant messaging, and chat rooms, and discussion groups for your local users or business, you need dbabble! -- See http://netwinsite.com/sponsor/sponsor_dbabble.htm ---- -- http://mail.python.org/mailman/listinfo/python-list