Implemented the isSessionValid method