Porting session management to C++