Yeah, it should definitely work. Just make sure on the PHP side you're checking if userId < 0. The getUserId() function returns -1 if no user is found.