This is a backport of 4d817b3, which fixed incorrect pickling of cookies. Given that this bug can result in scrambled CSRF token cookies (discouraging their use), I think it's worth it.
The related ticket is 19262.
Fixed #19262 -- Support cookie pickling in SimpleTemplateResponse
Closing as per ticket resolution.