Fix issue with localStorage error on Firefox

Firefox raises an error if window.localStorage is accessed when cookies
are disabled:

https://bugzilla.mozilla.org/show_bug.cgi?id=771890