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