【发布时间】:2012-03-07 02:37:29
【问题描述】:
我正在尝试使用 localhost 在我的开发机器上设置一个 cookie。下面是我的 web.py 代码。但是,当我在 http://0.0.0.0:8080/ 的 te bowser 中运行代码时,我得到一个页面,但没有设置 cookie。仅供参考主机名--fqdn 等于“ubuntu”。这是我第一次尝试设置 cookie。我也试过 ubuntu,127.0.0.1 以及 doman。
class index:
def GET(self):
env = web.ctx['environ']
qs = urlparse.parse_qs(env['QUERY_STRING'])
#Set cookie
web.setcookie('test', "rtb", expires=3600, domain='localhost', secure=False)
return 'test'
【问题讨论】:
-
PS 我将“0.0.0.0 dev”添加到 /etc/hosts 并使用域 dev 但仍然无济于事