Updated to get userId and cookies