Read session UUID from cookie if header is missing. Bump to v0.2.14

This commit is contained in:
Magnus Åhall 2024-05-08 18:10:06 +02:00
parent aecafc2986
commit 452a109204
1 changed files with 6 additions and 1 deletions

7
pkg.go
View File

@ -64,7 +64,7 @@ import (
"strings"
)
const VERSION = "v0.2.13"
const VERSION = "v0.2.14"
type HttpHandler func(http.ResponseWriter, *http.Request)
@ -376,6 +376,11 @@ func sessionUUID(r *http.Request) (string, error) { // {{{
headers := r.Header["X-Session-Id"]
if len(headers) > 0 {
return headers[0], nil
} else {
cookie, err := r.Cookie("X-Session-ID")
if err == nil && cookie.Value != "" {
return cookie.Value, nil
}
}
return "", errors.New("Invalid session")
} // }}}