fix infinite loop
Merge pull request #3616 from tamland/cookiefix

fix infinite loop