You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
devops/routes/logout.go

21 lines
558 B

3 months ago
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, "/")
}