support for localstorage, fallback to cookies