1

I am using Echo for my web application. I tried to implement Login and Logout. When I tried to logout, its not clearing the session. Here is my code:

func Logout(c echo.Context) error {
    sess, _ := session.Get("session", c)
    sess.Options = &sessions.Options{
        Path:     "/",
        MaxAge:   -1,
        HttpOnly: true,
    }
    sess.Values["username"] = ""
    sess.Values["authenticated"] = ""
    sess.Save(c.Request(), c.Response())
    return c.Redirect(http.StatusSeeOther, "/")
}

After logout I checked the session values, its not changing or clearing anything. I am using these packages for session management:

"github.com/labstack/echo-contrib/session"
"github.com/gorilla/sessions"
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
pyprism
  • 2,928
  • 10
  • 46
  • 85

1 Answers1

-1

The problem is in the client side . Browsers are ignoring Set-Cookie in redirect response when domain of the cookie is localhost. So I have to use 127.0.0.1 instead of localhost.

pyprism
  • 2,928
  • 10
  • 46
  • 85