You should use Context::getContext()->cart->id instead of $cookie