package routes import ( "net/http" "zestack.dev/slim" ) func handleLogout(c slim.Context) error { // Get a session. We're ignoring the error resulted from decoding an // existing session: Get() always returns a session, even if empty. session, _ := store.Get(c.Request(), "session-name") // Set some session values. session.Values["foo"] = nil // Save it before we write to the response/return from the handler. err := session.Save(c.Request(), c.Response()) if err != nil { return err } return c.Redirect(http.StatusMovedPermanently, "/") }