def parse_cookies(http_cookie):
 if ('"' in http_cookie):
  cookie = Cookie.SimpleCookie()
  try:
   cookie.load(http_cookie)
  except Cookie.CookieError:
   cookie = Cookie.SimpleCookie()
   for attr_value in http_cookie.split(';'):
    try:
     cookie.load(attr_value)
    except Cookie.CookieError:
     pass
  cookies = dict(((k, urllib.unquote(v.value)) for (k, v) in cookie.iteritems()))
 else:
  cookies = {}
  for key_value in http_cookie.split(';'):
   key_value = key_value.split('=', 1)
   if (len(key_value) == 2):
    (key, value) = key_value
    cookies[key.strip()] = urllib.unquote(value.strip())
 return cookies

def parse_cookies ( http_cookie ) : if ( '"' in http_cookie ) : cookie = Cookie . SimpleCookie ( ) try : cookie . load ( http_cookie ) except Cookie . CookieError : cookie = Cookie . SimpleCookie ( ) for attr_value in http_cookie . split ( ';' ) : try : cookie . load ( attr_value ) except Cookie . CookieError : pass cookies = dict ( ( ( k , urllib . unquote ( v . value ) ) for ( k , v ) in cookie . iteritems ( ) ) ) else : cookies = { } for key_value in http_cookie . split ( ';' ) : key_value = key_value . split ( '=' , 1 ) if ( len ( key_value ) == 2 ) : ( key , value ) = key_value cookies [ key . strip ( ) ] = urllib . unquote ( value . strip ( ) ) return cookies
parse a http_cookie header and return dict of cookie names and decoded values .