'Alternate for Cookie in Javascript [closed]
I'm currently using cookie to store value via JavaScript in client side in IE6 older version
Is there is any other way to store values so that it can be retrieved when user navigates to different pages?
Is there a way to store values in the server via JavaScript without exposing a API in the server or any API which works in old and new browsers?
Is there a way to store values in a file via JavaScript?
Solution 1:[1]
Supporting IE6 is not a good idea; even if you are working on some legacy kiosk or something, get them to upgrade!
But to your answers:
- No/Sortof -- the other way to do what you want is with localStorage, which was not introduced to IE until 8. You could redesign your app so that instead of different "pages" they are a single page web app; but that's no pleasure in IE6.
- No -- For javascript to store values on the server, it needs to send data over the internet. When the client (your javascript in the browser) sends data to the server, that is, by definition, accessing an API. (I don't know what you mean by "or any api that works in old and new browsers" -- that clause doesn't make any sense to me.)
- Maybe--but you don't want to. Javascript is prevented from accessing the local file system without explicit user permission, so you can't use the local filesystem to invisibly store data. That's what localStorage is for, but not available in IE6. If you want to explicitly save something as a file, with user choosing the file from a standard popup-window, that is not an easy process, especially in earlier browsers.
In short: I don't know why you're using IE6, and I don't know why you're not using cookies or an ajax call to the server, but those would be your best options.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Blunt Jackson |
