Web2py uses a Python's SimpleCookie objects for storing cookies in request.cookies and setting them in response.cookies.
To set a cookie which expires in 1 day use:
response.cookies['name'] = value
response.cookies['expires'] = 3600 * 24
If you want the cookie to be accessible from other functions/controllers, you need to set the path of the cookie:
response.cookies['name']['path'] = '/'
Of course you can set it to something else, and then it will be only accessible from that path or below.
You can then access your cookie like this:
If the cookie is not set, then `request.cookies['name'] will not be set, so you might want to check before accessing it:
if request.cookies.has_key ('name'): #can use cookie