More robust cookie parsing

We had similar problems as described in issue #4 - they resulted from markup in cookies that broke the parsing.

Adapting the cookie parsing solved the problem for us.