Answer the question
In order to leave comments, you need to log in
How to make the remember me functionality in a Go web application?
Hello.
Suggest a solution.
based on www.gorillatoolkit.org/pkg/sessions made user authorization
sessionStore = sessions.NewCookieStore([]byte(config.Secret))
sessionStore.Options = &sessions.Options{
HttpOnly: true,
Secure: false,
}
session.Options = &sessions.Options{MaxAge: 86400 * 7}
Answer the question
In order to leave comments, you need to log in
In general, I read on the Internet that you don’t need to change anything in the session cookie itself, but you just need to create another remember_me cookie that will contain something completely secret, which will allow you to identify the user on the server side and log in. And already in this very cookie, set the MaxAge you need.
Here it is very cool written about it and not only about it, but also about the entire authorization system as a whole.
stackoverflow.com/questions/549/the-definitive-gui...
about remember_me, I advise you to read
fishbowl.pastiche.org/2004/01/19/persistent_login_...
Try
sessionStore.Options = &sessions.Options{
HttpOnly: true,
Secure: false,
}
And don't forgetsession.Save(r, w)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question