use accessor to get session

see https://github.com/owncloud/core/pull/9681

This can safely be backported to OC7 because the server container already contains a getSession() that in turn returns \OC::$session.

@VicDeo @DeepDiver1975 @karlitschek @craigpg