Allow apps to create custom session handlers.
Merge pull request #8847 from owncloud/stable6_backport_8557

Stable6 backport of #8557