UnsetSessionCookie unsets the session cookie
(w http.ResponseWriter)
| 56 | |
| 57 | // UnsetSessionCookie unsets the session cookie |
| 58 | func UnsetSessionCookie(w http.ResponseWriter) { |
| 59 | expire := time.Now().Add(time.Hour * -24 * 30) |
| 60 | cookie := http.Cookie{ |
| 61 | Name: "id", |
| 62 | Value: "", |
| 63 | Expires: expire, |
| 64 | Path: "/", |
| 65 | HttpOnly: true, |
| 66 | } |
| 67 | |
| 68 | w.Header().Set("Cache-Control", "no-cache") |
| 69 | http.SetCookie(w, &cookie) |
| 70 | } |
| 71 | |
| 72 | // DoError logs the error and responds with the given status code with a generic status text |
| 73 | func DoError(w http.ResponseWriter, msg string, err error, statusCode int) { |
no test coverage detected