Improved session and flash cookie encoding
Factored out the cookie data codec and provided tests