made the cookie check more robust, in case a user's cookie is invalid