use accessor to get session

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