diff options
-rw-r--r-- | sessions.go | 1 | ||||
-rw-r--r-- | store.go | 12 |
2 files changed, 7 insertions, 6 deletions
diff --git a/sessions.go b/sessions.go index 865d952..dc65b9e 100644 --- a/sessions.go +++ b/sessions.go @@ -193,6 +193,7 @@ func NewCookie(ctx echo.Context, name, value string) *http.Cookie { } // SetCookie for echo +// @param:ctx,key,value,maxAge(seconds),path(/),domain,secure,httpOnly,sameSite(lax/strict/default) func SetCookie(ctx echo.Context, key string, value string, args ...interface{}) { ctx.SetCookie(key, value, args...) } @@ -30,7 +30,8 @@ type Store interface { New(ctx echo.Context, name string) (*Session, error) // Save should persist session to the underlying store implementation. - Save(ctx echo.Context, s *Session) error + // @param args:maxAge(seconds),path(/),domain,secure,httpOnly,sameSite(lax/strict/default) + Save(ctx echo.Context, s *Session, args ...interface{}) error } // CookieStore ---------------------------------------------------------------- @@ -95,13 +96,13 @@ func (s *CookieStore) New(ctx echo.Context, name string) (*Session, error) { } // Save adds a single session to the response. -func (s *CookieStore) Save(ctx echo.Context, session *Session) error { +func (s *CookieStore) Save(ctx echo.Context, session *Session, args ...interface{}) error { encoded, err := securecookie.EncodeMulti(session.Name(), session.Values, s.Codecs...) if err != nil { return err } - SetCookie(ctx, session.Name(), encoded) + SetCookie(ctx, session.Name(), encoded, args...) return nil } @@ -189,8 +190,7 @@ func (s *FilesystemStore) New(ctx echo.Context, name string) (*Session, error) { } // Save adds a single session to the response. -func (s *FilesystemStore) Save(ctx echo.Context, - session *Session) error { +func (s *FilesystemStore) Save(ctx echo.Context, session *Session, args ...interface{}) error { // Delete if max-age is < 0 if ctx.CookieOptions().MaxAge < 0 { if err := s.erase(session); err != nil { @@ -214,7 +214,7 @@ func (s *FilesystemStore) Save(ctx echo.Context, if err != nil { return err } - SetCookie(ctx, session.Name(), encoded) + SetCookie(ctx, session.Name(), encoded, args...) return nil } |