How do I send the “Set-Cookie” header when working with a BaseHTTPServerRequestHandler, and Cookie? BaseCookie and children don’t provide a method to output the value to be passed into send_header(), and *Cookie.output() does not provide a HTTP line delimiter.
Which Cookie class should I be using? Two have survived into Python3, what are the differences?
Use
C = http.cookie.SimpleCookieto hold the cookies and thenC.output()to create the headers for it.Example here
The request handler has a
wfileattribute, which is the socket.