Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a good way to handle cookies in Pylons?

I've seen a few references that say there is WSGI middleware to do it, but I don't know a lot about the choices for WSGI middelware that handles cookies.

like image 296
Josh Gibson Avatar asked Dec 10 '22 20:12

Josh Gibson


1 Answers

You dont need anything special with pylons (0.9.7), it all works out of the box:

from pylons import request, response

#set a cookie
response.set_cookie( cookiename , some_string, max_age=180*24*3600 )

#read a cookie
request.cookies.get( cookiename )

#remove a cookie
request.cookies.pop( cookiename, None )

Pylons uses Webob (request, response) are (webob.Request, webob.Response) objects.

like image 132
Jochen Ritzel Avatar answered Feb 15 '23 03:02

Jochen Ritzel