2

我已经能够存储自定义 cookie,但我试图将其保存为会话,并在提交表单时将其存储在数据库中。我用:

func (c Application) Index(id string) revel.Result {
cookie := http.Cookie{Name: "id", Value: id, Domain: "localhost", Path: "/"}
c.SetCookie(&cookie)
return c.Render()
}

但我无法再次访问它。我怎样才能在不同的功能中检索它?

谢谢!

4

1 回答 1

3

我做错了。Revel 使用 Session 设置 cookie

设置:c.Session[key] = value

获取:c.Session[key]

于 2014-11-11T06:29:01.657 回答