diff --git a/mongodb_session/mongodb_session.module b/mongodb_session/mongodb_session.module
index e69b8d5..b3bc707 100644
--- a/mongodb_session/mongodb_session.module
+++ b/mongodb_session/mongodb_session.module
@@ -36,7 +36,10 @@ function mongodb_session_user_update($edit, $account) {
       ),
     );
     foreach (array('uid', 'created', 'access', 'login', 'status', 'picture') as $key) {
-      $save['$set'][$key] = (int) $save['$set'][$key];
+      // Make sure the key exists in the array before blindly updating.
+      if (isset($save['$set'][$key])) {
+        $save['$set'][$key] = (int) $save['$set'][$key];
+      }
     }
   }
   mongodb_collection('fields_current', 'user')->update(array('_id' => (int) $account->uid), $save, array('upsert' => TRUE));
