server session refactoring