What is the best way to set and get cookies in pylons/pyramid?
Response.set_cookie('example_cookie_name', 'example', max_age=180*24*3600)
returns the error
File "/usr/local/lib/python3.5/dist-packages/webob/response.py", line 1071, in set_cookie
self.headerlist.append(('Set-Cookie', cookie))
AttributeError: 'str' object has no attribute 'headerlist'
You seem to be doing something like this:
The problem is that
Responseis a class and you're calling its unbound methodset_cookiepassing a string in place of theselfargument.(Fun fact - in Python 2 the error is much clearer)
You need to either instantiate a new response object or simply use the
request.responseattribute.