MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / BuildDeleteSessionCookies

Function BuildDeleteSessionCookies

internal/cookie/cookie.go:81–109  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

79// cookies that cause browsers to delete the host-scoped and domain-scoped
80// session cookies. Transport-agnostic mirror of DeleteSession.
81func 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
112func GetSession(gc *gin.Context) (string, error) {

Callers 3

UpdateProfileMethod · 0.92
LogoutMethod · 0.92
DeleteSessionFunction · 0.85

Calls 2

GetHostPartsFunction · 0.92
GetDomainNameFunction · 0.92

Tested by

no test coverage detected