From 084b689d37295bdd73d66ee1c5212a7d040fedfc Mon Sep 17 00:00:00 2001 From: Gerasimos Maropoulos Date: Tue, 19 Jul 2016 06:35:52 +0300 Subject: [PATCH] Fix https://github.com/kataras/iris/issues/301 --- sessions.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sessions.go b/sessions.go index 95b38b8a..52c2fb3e 100644 --- a/sessions.go +++ b/sessions.go @@ -185,6 +185,7 @@ func (p *sessionProvider) read(sid string) *session { p.mu.Lock() if elem, found := p.sessions[sid]; found { p.mu.Unlock() // yes defer is slow + elem.Value.(*session).lastAccessedTime = time.Now() return elem.Value.(*session) } p.mu.Unlock() @@ -233,7 +234,8 @@ func (p *sessionProvider) gc(duration time.Duration) { // if the time has passed. session was expired, then delete the session and its memory place // we are not destroy the session completely for the case this is re-used after - if (elem.Value.(*session).lastAccessedTime.Unix() + duration.Nanoseconds()) < time.Now().Unix() { + + if time.Now().After(elem.Value.(*session).lastAccessedTime.Add(duration)) { p.list.Remove(elem) delete(p.sessions, elem.Value.(*session).sid) } else {