Code improvement on how to get session

Fixes bug 1295338

Change-Id: I28a860c91a7b22fd75b57595e18ba4c9a5ec5873
Merge "Code improvement on how to get session"