Added cookie check for isLoggedIn