More work to test Safari session cookie bug
1 files changed, 13 insertions(+), 8 deletions(-)

M sessions/echo_scs.go
M sessions/echo_scs.go +13 -8
@@ 68,15 68,20 @@ func LoadAndSaveWithConfig(config Sessio
 
 			c.Response().Before(func() {
 				if config.SessionManager.Status(ctx) != scs.Unmodified {
-					responseCookie := &http.Cookie{
-						Name:     config.SessionManager.Cookie.Name,
-						Path:     config.SessionManager.Cookie.Path,
-						Domain:   config.SessionManager.Cookie.Domain,
-						Secure:   config.SessionManager.Cookie.Secure,
-						HttpOnly: config.SessionManager.Cookie.HttpOnly,
-						SameSite: config.SessionManager.Cookie.SameSite,
-						MaxAge:   int(config.SessionManager.Lifetime),
+					responseCookie := new(http.Cookie)
+					responseCookie.Name = config.SessionManager.Cookie.Name
+					if config.SessionManager.Cookie.Path != "" {
+						responseCookie.Path = config.SessionManager.Cookie.Path
 					}
+					if config.SessionManager.Cookie.Domain != "" {
+						responseCookie.Domain = config.SessionManager.Cookie.Domain
+					}
+					if config.SessionManager.Cookie.SameSite != http.SameSiteDefaultMode {
+						responseCookie.SameSite = config.SessionManager.Cookie.SameSite
+					}
+					responseCookie.Expires = time.Now().Add(config.SessionManager.Lifetime)
+					responseCookie.Secure = config.SessionManager.Cookie.Secure
+					responseCookie.HttpOnly = config.SessionManager.Cookie.HttpOnly
 
 					switch config.SessionManager.Status(ctx) {
 					case scs.Modified: