from http import cookies c = cookies.SimpleCookie() c['user'] = 'admin' # Set the cookie expiration to two days from now c['user']['expires'] = 60 * 60 * 24 * 2 # Print out the cookie value print('Content-type: text/html') print(c.output())The output of the code above will be a simple HTTP headers containing the cookie value. Cookie Library: The Cookie module is a built-in Python library and does not require any additional package to be installed.