BuildDeleteSessionCookies returns the pair of zero-value, expired session cookies that cause browsers to delete the host-scoped and domain-scoped session cookies. Transport-agnostic mirror of DeleteSession.
(hostname string, appCookieSecure bool, sameSite http.SameSite)
| 79 | // cookies that cause browsers to delete the host-scoped and domain-scoped |
| 80 | // session cookies. Transport-agnostic mirror of DeleteSession. |
| 81 | func BuildDeleteSessionCookies(hostname string, appCookieSecure bool, sameSite http.SameSite) []*http.Cookie { |
| 82 | host, _ := parsers.GetHostParts(hostname) |
| 83 | domain := parsers.GetDomainName(hostname) |
| 84 | if domain != "localhost" { |
| 85 | domain = "." + domain |
| 86 | } |
| 87 | return []*http.Cookie{ |
| 88 | { |
| 89 | Name: constants.AppCookieName + "_session", |
| 90 | Value: "", |
| 91 | MaxAge: -1, |
| 92 | Path: "/", |
| 93 | Domain: host, |
| 94 | Secure: appCookieSecure, |
| 95 | HttpOnly: true, |
| 96 | SameSite: sameSite, |
| 97 | }, |
| 98 | { |
| 99 | Name: constants.AppCookieName + "_session_domain", |
| 100 | Value: "", |
| 101 | MaxAge: -1, |
| 102 | Path: "/", |
| 103 | Domain: domain, |
| 104 | Secure: appCookieSecure, |
| 105 | HttpOnly: true, |
| 106 | SameSite: sameSite, |
| 107 | }, |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | // GetSession gets the session cookie from context |
| 112 | func GetSession(gc *gin.Context) (string, error) { |
no test coverage detected