Browser persistence is a technique that allows you to store fairly large amounts of data in a browser, which, unlike cookies, are not sent to the server with every request.
Everything is already written to me, but I didn’t find any more or less detailed references in Habré, so I wrote a brief review on how it works and gathered links for more detailed study.
How it works
Firefox
Firefox 2+ implements the HTML5
Web Storage standard. The standard involves the storage of data in localStorage and sessionStorage objects, which differ in the scope of data.
Actually, saving and reading data is very simple - in key-value pairs of these objects (not only in FF, but also in other browsers that support Web storage):
sessionStorage["name"] = "";
var name = sessionStorage["name"];
')
In Firefox, there is also a globalStorage not described in the specification.
Yes, localStorage is implemented only in FF versions 3.5+.
Data size limit - 5MB per domain. You can read about them on the
Mozilla Developer Center website.
Internet Explorer
IE -
Web Storage is also
implemented in the eighth version.
The size of the stored data - up to 10MB.
In versions of IE 5-7 there is an interface
userData behavior . Data Restriction: 128K per page and 1024K per domain.
Safari
Web storage is
implemented in only the fourth version.
Other browsers
In other browsers, this is somehow deaf. If in Chrome I
mention our
mention of the fact that in the dev versions of the browser, you can enable support for localStorage, then with respect to Opera, I did not find any references at all.
But you can fix everything by using a small flash-movie in these browsers that uses the interface sharedObjects. That is, checked web storage and userData. Does not work? Insert the flash and use it.
Links
A ready-to-use library written by Ilya Cantor can be found here:
browserpersistence.ru .
A more detailed article by Ilya Kantor on
http://javascript.ru/unsorted/storage .
John Resig (by jQuery) article on DOM Storage:
http://ejohn.org/blog/dom-storage/And one more PersistJS library, but I have not tried it yet:
http://pablotron.org/?cid=1557