[Core] Add check for session being NULL so that we don't crash from cons...

...ole commands

This should solve at least some of the problems with writing commands from the console when no session exists