Whatever class you are running is not in a CMS context, otherwise it would have a session in the thread. As is explained on the page you referenced, you need to get a reference to the repository and login.
HippoRepository repository = HippoRepositoryFactory.getHippoRepository("vm://")
Then you can login to get a session. This does require you to be running in the same jvm as the repository.
What are you trying to achieve? I would generally expect you to have access to a session if you are running in the cms.