class watson.http.cookies.CookieDict(input=None)[source]

A dictionary containing cookies.

A basic extension of the SimpleCookie class from the standard library, but designed to work better with wsgi.


cd = CookieDict()
cookie = cd.add('my_cookie', 'some value')
print(cookie)  # my_cookie=some value
print(cd['my_cookie'])  # my_cookie=some value
add(name, value='', expires=0, path='/', domain=None, secure=False, httponly=False, comment=None)[source]

Convenience method to add cookies to the dict.

  • name – the name of the cookie
  • value – the value of the cookie
  • expires – the expiration date for the cookie in seconds
  • path – the path in which the cookie is valid
  • domain – the domain in which the cookie is valid
  • secure – only send cookies over https
  • httponly – only send over http requests, not accessible via JavaScript
  • comment – the associated comment with the cookie

The morsel that was added to the CookieDict


Expire a cookie the next time it is sent to the browser.

Parameters:name – the name of the cookie

Expire all the cookies in the dictionary.


Merges an existing cookie dict into another cookie dict.


Converts a HTTP_COOKIE from an environ dict into a CookieDict.