Skip to content

Commit

Permalink
update get session id
Browse files Browse the repository at this point in the history
  • Loading branch information
LyricTian committed Nov 20, 2018
1 parent b4e658c commit 5148957
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,22 @@ func (m *Manager) decodeSessionID(value string) (string, error) {

func (m *Manager) sessionID(r *http.Request) (string, error) {
var cookieValue string

cookie, err := r.Cookie(m.opts.cookieName)
if err == nil && cookie.Value != "" {
cookieValue = cookie.Value
} else if m.opts.enableSIDInURLQuery {
err := r.ParseForm()
if err != nil {
return "", err
} else {
if m.opts.enableSIDInURLQuery {
err := r.ParseForm()
if err != nil {
return "", err
}
cookieValue = r.FormValue(m.opts.cookieName)
}

if m.opts.enableSIDInHTTPHeader && cookieValue == "" {
cookieValue = r.Header.Get(m.opts.sessionNameInHTTPHeader)
}
cookieValue = r.FormValue(m.opts.cookieName)
} else if m.opts.enableSIDInHTTPHeader {
cookieValue = r.Header.Get(m.opts.sessionNameInHTTPHeader)
}

if cookieValue != "" {
Expand Down

0 comments on commit 5148957

Please sign in to comment.