Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

接口文档

https://godoc.org/github.com/gogf/gf/net/ghttp#Cookie

...

默认的SessionIdCookie中的存储名称为gfsession

使用示例

package main

import (
    "github.com/gogf/gf/frame/g"
    "github.com/gogf/gf/os/gtime"
    "github.com/gogf/gf/net/ghttp"
)

func main() {
    s := g.Server()
    s.BindHandler("/cookie", func(r *ghttp.Request) {
        datetime := r.Cookie.Get("datetime")
        r.Cookie.Set("datetime", gtime.Datetime())
        r.Response.Write("datetime:", datetime)
    })
    s.SetPort(8199)
    s.Run()
}

...