Fix logout issue with tokens
Merge pull request #5583 from frisco82/backportCookieChanges

Backport of  #3985 (Invalid remember me token)