simplify ways to detect cookie
Merge pull request #32 from wangsha/pullrequests/cookie-fix

simplify ways to detect cookie