## 1.11.10 Custom Cookie Handling

To understand how cookies work you may want to first read `The HTTP Protocol and Cookie Handling` sub section of the `Background Information` section of this documentation.

If you don't want to have headers sent automatically when using the `create()` and `destroy()` methods you can set the sendCookieHeaders parameter to `False`. In this case the header is instead appended to the `response_headers` attribute in the form of a tuple `(type, info)` where `type` is the header type eg `Set-Cookie` and info is the header information.

To send the headers you can use `sendCookieHeaders()` to send all the headers. Once the headers are sent they are appended to the `response_headers` attribute for debugging purposes.

Alternatively you can retrieve the last header and turn it back into a usual HTTP header using this code:

    cookieHeader = "%s: %s"%manager.response_headers[-1]

If you want to build your own cookie headers you can use `setCookieString(maxAge)` and `deleteCookieString()` which return HTTP headers as strings suitable for printing directly.

Finally, cookies are read from the `HTTP_COOKIE` environmental variable. If you wish to provide your own environment dictionary instead of the default (if for example you are using a WSGI application) you can read a cookie like this:

    sessionID = manager.cookieSessionID(environ=environ)

See the API documentation for more information.