Set a cookie using the same API on both the client and the server.