Adds session api for authentication

Ups, working on two pr on the same time. Fixed.