title: Could not expire a cookie
body: <p>I'm playing with the Go App Engine SDK and I'm trying to set/expires Cookies.</p>
  
  <p>There is no problem by setting a Cookie, but it is impossible to make it expiring in the browser.</p>
  
  <p>The app is a based on a <code>negroni</code> instance: </p>
  
  <pre><code>func init() {
  
      app := negroni.New()
      app.UseHandler(Router())
      http.Handle("/", app)
  
  }
  </code></pre>
  
  <p>The router is a <code>mux</code> instance:</p>
  
  <pre><code>func Router() *mux.Router {
  
      r := mux.NewRouter()
      subRouter := r.PathPrefix(PATH_PREFIX).Subrouter()
  
      subRouter.HandleFunc("/sign", LoginHandler)
      subRouter.HandleFunc("/userinfo", UserInfo)
      subRouter.HandleFunc("/logout", Logout)
  
      return r
  }
  </code></pre>
  
  <p>The login handler is basic:</p>
  
  <pre><code>func LoginHandler(w http.ResponseWriter, r *http.Request) {
  
      ctx := appengine.NewContext(r)
  
      u := user.Current(ctx)
  
      if u == nil {
  
          url, err := user.LoginURL(ctx, r.URL.String())
          if err != nil {
              http.Error(w, err.Error(), http.StatusInternalServerError)
              return
          }
          w.Header().Set("Location", url)
          w.WriteHeader(http.StatusFound)
          return
      }
  
      //COOKIE_ID = "SomeString"
      cookie := &amp;http.Cookie{Name: COOKIE_ID, Value: u.ID, Path: "/", MaxAge: 0}
      http.SetCookie(w, cookie)
  
      w.Header().Set("Location", "/")
      w.WriteHeader(http.StatusFound)
  }
  </code></pre>
  
  <p>To expires the cookie:</p>
  
  <pre><code>func Logout(w http.ResponseWriter, r *http.Request) {
  
      ctx := appengine.NewContext(r)
      url, err := user.LogoutURL(ctx, "/")
  
      if err != nil {
          http.Error(w, err.Error(), http.StatusInternalServerError)
          return
      }
  
      expiredCookie := &amp;http.Cookie{Name: COOKIE_ID, MaxAge: -10, Expires: time.Now()}
      http.SetCookie(w, expiredCookie)
  
      w.Header().Set("Location", url)
      w.WriteHeader(http.StatusFound)
  }
  </code></pre>
  
  <p>I tried everything:</p>
  
  <ul>
  <li>Getting the old cookie, change MaxAge and Expires</li>
  <li>Create a new cookie with the same Name to overwrite</li>
  </ul>
  
  <p>Full code: <a href="https://gist.github.com/yageek/78e43c83b56467fc8338" rel="nofollow noreferrer">https://gist.github.com/yageek/78e43c83b56467fc8338</a></p>
  
  <p>In any case, the cookie still remains in the navigator. What do I do wrong ?</p>