diff --git a/main.go b/main.go index 518b1cc..e730059 100644 --- a/main.go +++ b/main.go @@ -40,7 +40,10 @@ func (service *Service) httpTrack(w http.ResponseWriter, r *http.Request) { } else { cookie.Expires = time.Now().Add(service.CookieTTL) http.SetCookie(w, cookie) - service.RecurringSessions.Touch(cookie.Value) + + if !service.NewSessions.Contains(cookie.Value) { + service.RecurringSessions.Touch(cookie.Value) + } } service.writeEmptyGif(w, r) diff --git a/tracker.go b/tracker.go index f8cb226..6667eae 100644 --- a/tracker.go +++ b/tracker.go @@ -64,6 +64,13 @@ func (tracker *Tracker) Debugf(msg string, args ...interface{}) { } } +func (tracker *Tracker) Contains(sessionID string) bool { + tracker.bucketMutex.Lock() + _, ok := tracker.buckets[sessionID] + tracker.bucketMutex.Unlock() + return ok +} + func (tracker *Tracker) Touch(sessionID string) { tracker.bucketMutex.Lock()