Move all the operations related to reading cookie into a function
Validate user data. Fixes #18 and #22