I would strongly suggest preferring local storage to a cookie, cookies add extra bytes to every request against the domain, and can potentially be deleted server side (lots of european web servers will actively expire cookies they don't recognize these days).