extracted server specific code from sessions so it can be reusable with client code