-
Notifications
You must be signed in to change notification settings - Fork 1
/
steranko_signout.go
24 lines (19 loc) · 957 Bytes
/
steranko_signout.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package steranko
import (
"net/http"
"github.com/labstack/echo/v4"
)
// SignOut implements the echo.HandlerFunc, and can be used directly
// in your REST API, or can be wrapped by your own custom function.
func (s *Steranko) SignOut(ctx echo.Context) error {
ctx.SetCookie(&http.Cookie{
Name: cookieName(ctx.Request()), // Get the Cookie name to use for this context.
Value: "", // Erase the value of the cookie
MaxAge: 0, // Expires the cookie immediately
Path: "/", // This allows the cookie on all paths of this site.
Secure: ctx.IsTLS(), // Set secure cookies if we're on a secure connection
HttpOnly: true, // Cookies should only be accessible via HTTPS (not client-side scripts)
SameSite: http.SameSiteStrictMode, // Strict same-site policy prevents cookies from being used by other sites.
})
return nil
}