Improved exception handling in isloggedin.js