session: use custom types for session flags and state