Skip to content

Commit

Permalink
fix: resolve cookie issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Jul 16, 2020
1 parent 753eb86 commit 6e2b6d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .schema/config.schema.json
Expand Up @@ -889,7 +889,7 @@
"default": "Lax"
}
},
"additionalProperties": false,
"additionalProperties": false
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions session/manager_http.go
Expand Up @@ -62,9 +62,15 @@ func (s *ManagerHTTP) CreateToRequest(ctx context.Context, w http.ResponseWriter
func (s *ManagerHTTP) SaveToRequest(ctx context.Context, w http.ResponseWriter, r *http.Request, session *Session) error {
_ = s.r.CSRFHandler().RegenerateToken(w, r)
cookie, _ := s.r.CookieManager().Get(r, s.cookieName)
cookie.Options.Domain = s.c.SessionDomain()
cookie.Options.Path = s.c.SessionPath()
cookie.Options.SameSite = s.c.SessionSameSiteMode()
if s.c.SessionDomain() != "" {
cookie.Options.Domain = s.c.SessionDomain()
}
if s.c.SessionPath() != "" {
cookie.Options.Path = s.c.SessionPath()
}
if s.c.SessionSameSiteMode() != 0 {
cookie.Options.SameSite = s.c.SessionSameSiteMode()
}
cookie.Values["sid"] = session.ID.String()
if err := cookie.Save(r, w); err != nil {
return errors.WithStack(err)
Expand Down

0 comments on commit 6e2b6d2

Please sign in to comment.