@@ -148,13 +148,6 @@ func (store *SessionStore) loadSessionFromString(value string) (*sessions.Sessio
148// Clear clears any saved session information for a given ticket cookie
148// Clear clears any saved session information for a given ticket cookie
149// from redis, and then clears the session
149// from redis, and then clears the session
150func (store *SessionStore) Clear(rw http.ResponseWriter, req *http.Request) error {
150func (store *SessionStore) Clear(rw http.ResponseWriter, req *http.Request) error {
151− requestCookie, _ := req.Cookie(store.CookieOptions.CookieName)
153− val, _, ok := cookie.Validate(requestCookie, store.CookieOptions.CookieSecret, store.CookieOptions.CookieExpire)
155− return fmt.Errorf("Cookie Signature not valid")
158 // We go ahead and clear the cookie first, always.
151 // We go ahead and clear the cookie first, always.
159 clearCookie := store.makeCookie(
152 clearCookie := store.makeCookie(
@@ -164,6 +157,20 @@ func (store *SessionStore) Clear(rw http.ResponseWriter, req *http.Request) erro
165 http.SetCookie(rw, clearCookie)
158 http.SetCookie(rw, clearCookie)
160+ // If there was an existing cookie we should clear the session in redis
161+ requestCookie, err := req.Cookie(store.CookieOptions.CookieName)
162+ if err != nil && err == http.ErrNoCookie {
163+ // No existing cookie so can't clear redis
165+ } else if err != nil {
166+ return fmt.Errorf("error retrieving cookie: %v", err)
169+ val, _, ok := cookie.Validate(requestCookie, store.CookieOptions.CookieSecret, store.CookieOptions.CookieExpire)
171+ return fmt.Errorf("Cookie Signature not valid")
167 // We only return an error if we had an issue with redis
174 // We only return an error if we had an issue with redis
168 // If there's an issue decoding the ticket, ignore it
175 // If there's an issue decoding the ticket, ignore it
169 ticket, _ := decodeTicket(store.CookieOptions.CookieName, val)
176 ticket, _ := decodeTicket(store.CookieOptions.CookieName, val)