1
0
mirror of https://github.com/alexedwards/scs.git synced 2025-07-15 01:04:36 +02:00

feat: add SetDeadline method

This commit is contained in:
fnoopv
2023-10-23 15:25:28 +08:00
parent 84bd122bd8
commit b1eea39ac8

13
data.go
View File

@ -577,6 +577,19 @@ func (s *SessionManager) Deadline(ctx context.Context) time.Time {
return sd.deadline
}
// SetDeadline updates the 'absolute' expiry time for the session. Please note
// that if you are using an idle timeout, it is possible that a session will
// expire due to non-use before the set deadline.
func (s *SessionManager) SetDeadline(ctx context.Context, expire time.Time) {
sd := s.getSessionDataFromContext(ctx)
sd.mu.Lock()
defer sd.mu.Unlock()
sd.deadline = expire
sd.status = Modified
}
// Token returns the session token. Please note that this will return the
// empty string "" if it is called before the session has been committed to
// the store.