The following code shows how to set a cookie in your CherryPy code:
CherryClass Root: view: def index(self): response.simpleCookie['cookieName']='cookieValue' response.simpleCookie['cookieName']['path']='/' response.simpleCookie['cookieName']['max-age']=3600 response.simpleCookie['cookieName']['version']=1 return "<html><body>Hello, I just sent you a cookie</body></html>"
The following code shows how to read a cookie in your CherryPy code:
CherryClass Root: mask: def index(self): <html><body> Hi, you sent me <py-eval="len(request.simpleCookie)"> cookies.<br> Here is a list of cookie names/values:<br> <py-for="cookieName in request.simpleCookie.keys()"> <py-eval="cookieName+': '+request.simpleCookie[cookieName].value"><br> </py-for> </body></html>
See About this document... for information on suggesting changes.