Use encoding/json to serialise cookie

You shouldn't use encodings for cookies that no one can easily use in another programming language. I want to be able to create/access the cookies from other systems too, so I changed the encoder to JSON.