Fix the issue when cookies were invalid under certain circumstances.