def addCookie(self, k, v, expires=None, domain=None, path=None,
                  max_age=None, comment=None, secure=None, httpOnly=False,
                  sameSite=None):
        """
        Set an outgoing HTTP cookie.

        In general, you should consider using sessions instead of cookies, see
        L{twisted.web.server.Request.getSession} and the
        L{twisted.web.server.Session} class for details.

        @param k: cookie name
        @type k: L{bytes} or L{unicode}

        @param v: cookie value
        @type v: L{bytes} or L{unicode}

        @param expires: cookie expire attribute value in
            "Wdy, DD Mon YYYY HH:MM:SS GMT" format
        @type expires: L{bytes} or L{unicode}

        @param domain: cookie domain
        @type domain: L{bytes} or L{unicode}

        @param path: cookie path
        @type path: L{bytes} or L{unicode}

        @param max_age: cookie expiration in seconds from reception
        @type max_age: L{bytes} or L{unicode}

        @param comment: cookie comment
        @type comment: L{bytes} or L{unicode}

        @param secure: direct browser to send the cookie on encrypted
            connections only
        @type secure: L{bool}

        @param httpOnly: direct browser not to expose cookies through channels
            other than HTTP (and HTTPS) requests
        @type httpOnly: L{bool}

        @param sameSite: One of L{None} (default), C{'lax'} or C{'strict'}.
            Direct browsers not to send this cookie on cross-origin requests.
            Please see:
            U{https://tools.ietf.org/html/draft-west-first-party-cookies-07}
        @type sameSite: L{None}, L{bytes} or L{unicode}

        @raises: L{DeprecationWarning} if an argument is not L{bytes} or
            L{unicode}.
            L{ValueError} if the value for C{sameSite} is not supported.
        """
        def _ensureBytes(val):
            """
            Ensure that C{val} is bytes, encoding using UTF-8 if
            needed.

            @param val: L{bytes} or L{unicode}

            @return: L{bytes}
            """
            if val is None:
                # It's None, so we don't want to touch it
                return val

            if isinstance(val, bytes):
                return val
            else:
                return val.encode('utf8')


        def _sanitize(val):
            """
            Replace linear whitespace (C{\r}, C{\n}, C{\r\n}) and
            semicolons C{;} in C{val} with a single space.

            @param val: L{bytes}
            @return: L{bytes}
            """
            return _sanitizeLinearWhitespace(val).replace(b';', b' ')

        cookie = (
            _sanitize(_ensureBytes(k)) +
            b"=" +
            _sanitize(_ensureBytes(v)))
        if expires is not None:
            cookie = cookie + b"; Expires=" + _sanitize(_ensureBytes(expires))
        if domain is not None:
            cookie = cookie + b"; Domain=" + _sanitize(_ensureBytes(domain))
        if path is not None:
            cookie = cookie + b"; Path=" + _sanitize(_ensureBytes(path))
        if max_age is not None:
            cookie = cookie + b"; Max-Age=" + _sanitize(_ensureBytes(max_age))
        if comment is not None:
            cookie = cookie + b"; Comment=" + _sanitize(_ensureBytes(comment))
        if secure:
            cookie = cookie + b"; Secure"
        if httpOnly:
            cookie = cookie + b"; HttpOnly"
        if sameSite:
            sameSite = _ensureBytes(sameSite).lower()
            if sameSite not in [b"lax", b"strict"]:
                raise ValueError(
                    "Invalid value for sameSite: " + repr(sameSite))
            cookie += b"; SameSite=" + sameSite
        self.cookies.append(cookie)

        Set an outgoing HTTP cookie.

        In general, you should consider using sessions instead of cookies, see
        L{twisted.web.server.Request.getSession} and the
        L{twisted.web.server.Session} class for details.

        @param k: cookie name
        @type k: L{bytes} or L{unicode}

        @param v: cookie value
        @type v: L{bytes} or L{unicode}

        @param expires: cookie expire attribute value in
            "Wdy, DD Mon YYYY HH:MM:SS GMT" format
        @type expires: L{bytes} or L{unicode}

        @param domain: cookie domain
        @type domain: L{bytes} or L{unicode}

        @param path: cookie path
        @type path: L{bytes} or L{unicode}

        @param max_age: cookie expiration in seconds from reception
        @type max_age: L{bytes} or L{unicode}

        @param comment: cookie comment
        @type comment: L{bytes} or L{unicode}

        @param secure: direct browser to send the cookie on encrypted
            connections only
        @type secure: L{bool}

        @param httpOnly: direct browser not to expose cookies through channels
            other than HTTP (and HTTPS) requests
        @type httpOnly: L{bool}

        @param sameSite: One of L{None} (default), C{'lax'} or C{'strict'}.
            Direct browsers not to send this cookie on cross-origin requests.
            Please see:
            U{https://tools.ietf.org/html/draft-west-first-party-cookies-07}
        @type sameSite: L{None}, L{bytes} or L{unicode}

        @raises: L{DeprecationWarning} if an argument is not L{bytes} or
            L{unicode}.
            L{ValueError} if the value for C{sameSite} is not supported.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/http.py