Use cookie instead of terrible globals