Convert session to hash before cleaning env

With Rails, using Marshal.dump(env['rack.session']) raises an error.
Converting to a hash first allows it to be dumped.