'Create a new cookie or replace an old one. If the `secret` parameter is
set, create a `Signed Cookie` (described below).:param key: the name of the cookie.
:param value: the value of the cookie.:param secret: a signature key required for
signed cookies.
Additionally, this method accepts all RFC 2109 attributes that are
supported by :class:`cookie.Morsel`, including::param max_age: maximum age in seconds.
(default: None):param expires: a datetime object or UNIX timestamp.
(default: None):param domain:
the domain that is allowed to read the cookie.
(default: current domain):param path: limits the cookie to a given path
(default: ``/``):param secure: limit the cookie to HTTPS connections (default: off).
:param httponly:
prevents client-side javascript to read this cookie
(default: off, requires Python 2.6 or newer).
If neither `expires` nor `max_age` is set (default), the cookie will
expire at the end of the browser session (as soon as the browser
window is closed).
Signed cookies may store any pickle-able object and are
cryptographically signed to prevent manipulation. Keep in mind that
cookies are limited to 4kb in most browsers.
Warning: Signed cookies are not encrypted (the client can still see
the content) and not copy-protected (the client can restore an old
cookie). The main intention is to make pickling and unpickling
save, not to store secret information at client side.'

def set_cookie(self, key, value, secret=None, **options):

    if (not self._cookies):
        self._cookies = SimpleCookie()
    if secret:
        value = touni(cookie_encode((key, value), secret))
    elif (not isinstance(value, basestring)):
        raise TypeError('Secret    key    missing    for    non-string    Cookie.')
    self._cookies[key] = value
    for (k, v) in options.iteritems():
        self._cookies[key][k.replace('_', '-')] = v
