We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello Sau Sheong Chang,
Congratulations for the book, it's very useful.
The logout function in the book always triggers the warning and doesn't delete the browser cookie:
logout
warning
func logout(writer http.ResponseWriter, request *http.Request) { cookie, err := request.Cookie("_cookie") if err != http.ErrNoCookie { warning(err, "Failed to get cookie") session := data.Session{Uuid: cookie.Value} session.DeleteByUUID() } http.Redirect(writer, request, "/", 302) }
A possible solution could be:
func logout(writer http.ResponseWriter, request *http.Request) { cookie, err := request.Cookie("_cookie") if err != http.ErrNoCookie { session := data.Session{Uuid: cookie.Value} session.DeleteByUUID() cookie.MaxAge = -1 cookie.Expires = time.Unix(1, 0) http.SetCookie(writer, cookie) } else { warning(err, "Failed to get cookie") } http.Redirect(writer, request, "/", 302) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello Sau Sheong Chang,
Congratulations for the book, it's very useful.
The
logout
function in the book always triggers thewarning
and doesn't delete the browser cookie:A possible solution could be:
The text was updated successfully, but these errors were encountered: