Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

session存储数组/切片/map时,在当前也没有问题,其他页面会nil #3261

Open
langzishen opened this issue Aug 1, 2022 · 2 comments

Comments

@langzishen
Copy link

当使用session存储数组/切片/map数据类型是,在其他页面取出时会为nil,并且在没有报错的情况下导致其他后存入session的值也存储失败,全部都时nil,请看下图:

00
1-1
2-2
2-1
1-2

@qiuyuyin
Copy link

please english

@Chasing1020
Copy link

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{}).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants