Updated to use cookies on MSIE or when localStorage is unavailable, otherwise localStorage.
This is because MSIE doesn't support localStorage on file:// and Chrome doesn't support cookies on file://. And localStorage is preferable when possible.