gpt4 book ai didi

session - 让 Revel Controller 返回一个 cookie

转载 作者:IT王子 更新时间:2023-10-29 01:43:02 25 4
gpt4 key购买 nike

我已经能够存储自定义 cookie,但我正在尝试将其保存用于 session ,以便在提交表单时将其存储在数据库中。我使用:

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

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

谢谢!

最佳答案

我做错了。 Revel 通过 session 设置 cookie。

Set: 
c.Session[key] = value

Get:
c.Session[key]

关于session - 让 Revel Controller 返回一个 cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26729590/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com