Files
gf/.example/net/ghttp/server/session/session.go

23 lines
446 B
Go

package main
import (
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/net/ghttp"
"github.com/gogf/gf/os/gtime"
)
func main() {
s := g.Server()
s.SetSessionMaxAge(60)
s.SetSessionIdName("gpadminssid")
s.BindHandler("/set", func(r *ghttp.Request) {
r.Session.Set("time", gtime.Second())
r.Response.Write("ok")
})
s.BindHandler("/get", func(r *ghttp.Request) {
r.Response.WriteJson(r.Session.Map())
})
s.SetPort(8199)
s.Run()
}