I have the same issue but with the cookie key name I'm trying to set a cookie with name usercookie[username], but it seems using square brackets in the cookie key name makes a problem here, is there any work around for this problem?
>>> SimpleCookie('usercookie[username]=speedy; path=/; domain=mydomain.com') <SimpleCookie: > On May 15, 9:20 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote: > On Thu, May 15, 2008 at 12:29 PM, Chris Farley <[EMAIL PROTECTED]> wrote: > > My Django app needs to read acookiethat is written by a JavaScript > > script in another part of my website. The JavaScript code that > > generates thecookieis something like this: > > > document.cookie='ShoppingCart=[7008|2][7120|3]; path=/; > > domain=mydomain.com'; > > > I can see thecookieand its content from Firefox and Safari when I > > "view cookies". Django's request.COOKIES dictionary contains a key for > > the 'ShoppingCart'cookie, but the content is always an empty string. > > > Is this a feature or a bug? > > I'm not sure if it's a feature or a bug, but it's certainly not > Django's doing. If you try the following in a Python shell, you'll see > that this behavior is part of Python's owncookiehandling. > > >>> fromCookieimport SimpleCookie > >>> SimpleCookie('ShoppingCart=[7008|2][7120|3]; path=/; domain=mydomain.com') > > <SimpleCookie: ShoppingCart=''> > > But, if you quote thecookie'svalue ... > > >>> SimpleCookie('ShoppingCart="[7008|2][7120|3]"; path=/; > >>> domain=mydomain.com') > > <SimpleCookie: ShoppingCart='[7008|2][7120|3]'> > > I don't know if it'd be easier for you to quote the value or just > avoidsquarebrackets (since that's where SimpleCookie seems to > choke), but it looks like it should be easy enough to work around. > > -Gul --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---