1 Star 0 Fork 0

崔俊 / iris_v1111

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 911 Bytes
一键复制 编辑 原始数据 按行查看 历史
崔俊 提交于 2024-03-11 14:05 . first commit
package main
import (
"github.com/kataras/iris"
"github.com/kataras/iris/sessions"
)
func main() {
app := iris.New()
sess := sessions.New(sessions.Config{Cookie: "myappsessionid", AllowReclaim: true})
app.Get("/set", func(ctx iris.Context) {
s := sess.Start(ctx)
s.SetFlash("name", "iris")
ctx.Writef("Message setted, is available for the next request")
})
app.Get("/get", func(ctx iris.Context) {
s := sess.Start(ctx)
name := s.GetFlashString("name")
if name == "" {
ctx.Writef("Empty name!!")
return
}
ctx.Writef("Hello %s", name)
})
app.Get("/test", func(ctx iris.Context) {
s := sess.Start(ctx)
name := s.GetFlashString("name")
if name == "" {
ctx.Writef("Empty name!!")
return
}
ctx.Writef("Ok you are coming from /set ,the value of the name is %s", name)
ctx.Writef(", and again from the same context: %s", name)
})
app.Run(iris.Addr(":8080"))
}
1
https://gitee.com/cuijun/iris_v1111.git
git@gitee.com:cuijun/iris_v1111.git
cuijun
iris_v1111
iris_v1111
1a5f2c173b4a

搜索帮助