Added a sanity check for checking the validity of a session.