improve the serialization of custom user models

(cherry picked from commit 7b34eabe4b506c3e49e4dedbefee66c1612bb83d)
[#3307] Adding an additional note about deserialization issues

(cherry picked from commit 7325ec5044c0339275a9700e767d88707116f79d)
[#3307] Fix thanks to @xabbuh

(cherry picked from commit 38612bc190ab2f97f2fbd3f3bc18a591df153cbe)
Clarifying some details on serialize/unserialize and making it consistent with changes we recently made

(cherry picked from commit f285c5a572ee88e94a9314e152a5075243811d49)

Conflicts:
	cookbook/security/entity_provider.rst