Check for existance of cookies before using them.

Fixes instances where we try to get a value from a cookie which might
not have been set yet.
Merge pull request #34 from cornet/fix-error-on-missing-cookies

Check for existance of cookies before using them.