gin
gin copied to clipboard
session存储数组/切片/map时,在当前也没有问题,其他页面会nil
当使用session存储数组/切片/map数据类型是,在其他页面取出时会为nil,并且在没有报错的情况下导致其他后存入session的值也存储失败,全部都时nil,请看下图:
please english
When you want to save the cookie value as type map[string]string
by the method func (s *session) Save()
will return err like "gob: type not registered for interface: map[string]string".
Because the package "github.com/gin-contrib/sessions" uses the "encoding/gob" by default. You have to register your type beforehand by using gob.Register(map[string]string{})
.