watsonpy / watson-framework

A Python 3 web app framework.
BSD 3-Clause "New" or "Revised" License
104 stars 12 forks source link

cookies.get('name') #18

Closed mrwert closed 9 years ago

mrwert commented 9 years ago

Hello.

...cookies.get('name') -> return 'name=value' How do I get only 'value'?

Thanks you for the Watson Framework.

simoncoulton commented 9 years ago

Hey @mrwert, you'll be able to retrieve them off the Request object via the following:

Request.cookies['name']

Request.cookies returns a watson.http.cookies.CookieDict. Retrieving the cookie itself actually return a Morsel object which you can find the docs on that https://docs.python.org/2/library/cookie.html#Cookie.Morsel.

But basically:

name = Request.cookies['name']
name.value  # "value"