1
0
mirror of https://github.com/alexedwards/scs.git synced 2025-07-17 01:12:21 +02:00

Add LoadNew method

This commit is contained in:
Alex Edwards
2019-10-01 20:30:00 +02:00
parent 4cd374bf18
commit 05fd72191e

View File

@ -83,6 +83,15 @@ func (s *SessionManager) Load(ctx context.Context, token string) (context.Contex
return s.addSessionDataToContext(ctx, sd), nil
}
// LoadNew returns a new context.Context containing a new empty instance of
// session data.
//
// Most applications will use the LoadAndSave() middleware and will not need to
// use this method.
func (s *SessionManager) LoadNew(ctx context.Context) (context.Context, error) {
return s.addSessionDataToContext(ctx, newSessionData(s.Lifetime)), nil
}
// Commit saves the session data to the session store and returns the session
// token and expiry time.
//