diff --git masquerade.module masquerade.module
index f271498..ef73be5 100644
--- masquerade.module
+++ masquerade.module
@@ -56,7 +56,9 @@ function masquerade_init() {
   // $uid === 0 we want to store the session variable. If there's no record in
   // masquerade table we clear the session variable.
   if ($uid === FALSE) {
-    unset($_SESSION['masquerading']);
+    if (isset($_SESSION)) {
+      unset($_SESSION['masquerading']);
+    }
   }
   else {
     $_SESSION['masquerading'] = $uid;
