diff --git a/cas_auth/start.php b/cas_auth/start.php
index b4dbb8aa2abad17ca28d5421a469042fea62d8a2..effb5dd010432383c5dece0abd739568c7e46ac1 100644
--- a/cas_auth/start.php
+++ b/cas_auth/start.php
@@ -100,7 +100,7 @@
 	// Register the initialisation function
 	register_elgg_event_handler('init','system','cas_auth_init');
 	// Register CAS logout to main logout only if user logged with CAS
-	if ( $_SESSION['loggedWithCAS'] ) {
+	if (isset($_SESSION['loggedWithCAS']) && $_SESSION['loggedWithCAS']===true) {
 		register_elgg_event_handler('logout', 'user', 'logoutCas');
 	}