Add support for custom session cookie serializers

This is to ease integration with existing applications, in particular rails.

Current behaviour is maintained (serialize to ETF), but support for JSON is added.