Move session management support to their own file.