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

Will more complex value types be supported? #171

Open
BigeYoung opened this issue May 22, 2022 · 1 comment
Open

Will more complex value types be supported? #171

BigeYoung opened this issue May 22, 2022 · 1 comment

Comments

@BigeYoung
Copy link

func main() {
	r := gin.Default()
	store := cookie.NewStore([]byte("secret"))
	r.Use(sessions.Sessions("mysession", store))
	r.PUT("/hello", func(c *gin.Context) {
		session := sessions.Default(c)
		session.Set("hello", struct{ Name string }{Name: "gin"})
		err := session.Save()
		if err != nil {
			panic(err)
		}
		c.Status(204)
	})
	r.Run(":8000")
}

This code will throw error:

securecookie: error - caused by: gob: type not registered for interface: struct { Name string }

Since gorilla/sessions already supports complex data types in sessions, will gin/session consider following up?

@mrredo
Copy link

mrredo commented Jul 16, 2022

Use gob.Register to register the type i also had this issue i just registered the type and everything worked

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

2 participants