github.com/gogf/gf@v1.16.9/.example/net/ghttp/server/session.go (about) 1 package main 2 3 import ( 4 "github.com/gogf/gf/frame/g" 5 "github.com/gogf/gf/net/ghttp" 6 "github.com/gogf/gf/util/gconv" 7 ) 8 9 func main() { 10 s := g.Server() 11 s.BindHandler("/session", func(r *ghttp.Request) { 12 id := r.Session.GetInt("id") 13 r.Session.Set("id", id+1) 14 r.Response.Write("id:" + gconv.String(id)) 15 }) 16 s.SetPort(8199) 17 s.Run() 18 }