Added session handling to the api