From b1eea39ac8fc3e10c35a92a24eecb4a98213b0f0 Mon Sep 17 00:00:00 2001 From: fnoopv Date: Mon, 23 Oct 2023 15:25:28 +0800 Subject: [PATCH] feat: add SetDeadline method --- data.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/data.go b/data.go index 5caff27..f5585a9 100644 --- a/data.go +++ b/data.go @@ -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.