Delete Cookie and Display Template

时间:2018-03-22 23:25:25

标签: http go http-headers

I need to delete a cookie, and then display a "Logged out" page. I can't do both in one HandleFunc because, the Response is already written. Here's my code -- changing the order of renderTemplate and SetCookie doesn't help:

renderTemplate(w, "templates/logout.html", nil)
log.Println("Attempting to delete cookie:", app.CookieName)
http.SetCookie(w, &http.Cookie{
    Name:     app.CookieName,
    Value:    "",
    Domain:   ".example.com",
    Path:     "/",
    HttpOnly: true,
    MaxAge:   -1})

What's the best way to do this?

0 个答案:

没有答案
相关问题