#3746·tornado

the string value in 'set_cookie()' can not obtains space char

Author: ockanCreated Sep 28, 2026Updated Sep 28, 2026

the string value in 'set_cookie()' can not obtains space char

in tornado/web.set_cookie(), when cookie obtains space char

python
        if re.search(r"[\x00-\x20]", value):
            # Legacy check for control characters in cookie values. This check is no longer needed
            # since the cookie library escapes these characters correctly now. It will be removed
            # in the next feature release.
            raise ValueError(f"Invalid cookie {name!r}: {value!r}")

raise an error.