def set_cookie(self, name, value, secret=None, **options):
if not self._cookies:<EOL><INDENT>self._cookies = SimpleCookie()<EOL><DEDENT>if secret:<EOL><INDENT>value = touni(cookie_encode((name, value), secret))<EOL><DEDENT>elif not isinstance(value, str):<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>if len(value) > <NUM_LIT>: raise ValueError('<STR_LIT>')<EOL>self._cookies[name] = value<EOL>for key, value in options.items():<EOL><INDENT>if key == '<STR_LIT>':<EOL><INDENT>if isinstance(value, timedelta):<EOL><INDENT>value = value.seconds + value.days * <NUM_LIT> * <NUM_LIT><EOL><DEDENT><DEDENT>if key == '<STR_LIT>':<EOL><INDENT>if isinstance(value, (datedate, datetime)):<EOL><INDENT>value = value.timetuple()<EOL><DEDENT>elif isinstance(value, (int, float)):<EOL><INDENT>value = time.gmtime(value)<EOL><DEDENT>value = time.strftime("<STR_LIT>", value)<EOL><DEDENT>self._cookies[name][key.replace('<STR_LIT:_>', '<STR_LIT:->')] = value<EOL><DEDENT>
Create a new cookie or replace an old one. If the `secret` parameter is
            set, create a `Signed Cookie` (described below).

            :param name: 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: current path)
            :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.