cookies or storage or ..?

O

optimistx

If one would like to store in the user's local computer (= where the browser
is) some more data than the about 4 kilobytes the cookie can take, what to
do?

The word 'storage' was mentioned lately, but does it store during one
session only?

(Why not to store in the server? Yes, that is possible, but in this case I
would try to test the limits of javascript in the local computer... I love
javascript, just now, at least).

One idea is to pack data e.g. with LZH- algorithms, but they use 8 bits /
byte, and cookies allow only a subset. Allowed characters could be created
from the LZH- output bitstring (e.g. by picking 6 bits at a time, or perhaps
7), but this would probably be a bit messy. I could not with a 2 minute
search find an LZH- packer written in javascript, but there might be.

In this application some users might always be satisfied with the unpacked 4
kilobyte data, but some would prefer more.

Any ideas, more elegant perhaps?
 
T

The Natural Philosopher

optimistx said:
If one would like to store in the user's local computer (= where the browser
is) some more data than the about 4 kilobytes the cookie can take, what to
do?

The word 'storage' was mentioned lately, but does it store during one
session only?

(Why not to store in the server? Yes, that is possible, but in this case I
would try to test the limits of javascript in the local computer... I love
javascript, just now, at least).

One idea is to pack data e.g. with LZH- algorithms, but they use 8 bits /
byte, and cookies allow only a subset. Allowed characters could be created
from the LZH- output bitstring (e.g. by picking 6 bits at a time, or perhaps
7), but this would probably be a bit messy. I could not with a 2 minute
search find an LZH- packer written in javascript, but there might be.

In this application some users might always be satisfied with the unpacked 4
kilobyte data, but some would prefer more.

Any ideas, more elegant perhaps?
It seems to me that if you simply want to store in the page, javascript
variables work.

If you want to persist between pages, you have no recourse but the server.
 
J

Jorge

If one would like to store in the user's local computer (= where the browser
is) some more data than the about 4 kilobytes the cookie can take, what to
do?

The word 'storage' was mentioned lately, but does it store during one
session only?

(Why not to store in the server? Yes, that is possible, but in this case I
would try to test the limits of javascript in the local computer... I love
javascript, just now, at least).

One idea is to pack data e.g. with LZH- algorithms, but they use 8 bits /
byte, and cookies allow only a subset. Allowed characters could be created
from the LZH- output bitstring (e.g. by picking 6 bits at a time, or perhaps
7), but this would probably be a bit messy. I could not with a 2 minute
search find an LZH- packer written in javascript, but there might be.

In this application some users might always be satisfied with the unpacked 4
kilobyte data, but some would prefer more.

Any ideas, more elegant perhaps?

"HTML 5 client-side storage specification. One portion of that
specification is key-value storage. The purposes of key-value storage
are twofold:

To provide storage for cookie-like data specific to a single browser
window.
To provide local storage that does not get retransmitted with every
request to the server, thus making it practical to store larger
quantities of data than are practical with cookies.
To support those goals, the HTML 5 specification provides two key-
value storage objects: sessionStorage and localStorage.

The localStorage and sessionStorage JavaScript objects are
functionally identical except in their persistence and scope rules:

localStorage—used for long-term storage. This data persists after the
window is closed and is shared across all browser windows.
sessionStorage—used for ephemeral data related to a single browser
window. Data stored in the sessionStorage object does not persist
after the window is closed and is not shared with other windows.
If a new browser window is created when the user clicks a link, that
new window gets a copy of the sessionStorage object as it exists at
the time the window is created. The data is copied, not shared,
however, so future changes made by either page are not reflected in
the session storage for the other page.

Except for these differences, the localStorage and sessionStorage
objects behave identically.

Like cookies, these objects provide different sets of data to pages
served by different domains. Unlike cookies, the data is not
transmitted back to the server during normal browsing. If you need to
send the stored data back to the server, you must do so explicitly
using JavaScript and an XMLHttpRequest object."

http://developer.apple.com/safari/l...uide/Name-ValueStorage/Name-ValueStorage.html
http://www.w3.org/TR/webstorage/
https://developer.mozilla.org/en/DOM/Storage
 
T

Thomas 'PointedEars' Lahn

optimistx said:
If one would like to store in the user's local computer (= where the browser
is) some more data than the about 4 kilobytes the cookie can take, what to
do?

RTFM, as posted recently. (Also by me, incidentally.)
The word 'storage' was mentioned lately, but does it store during one
session only?

No. RTFM:

<http://en.wikipedia.org/wiki/DOM_storage>
[...]
One idea is to pack data e.g. with LZH- algorithms, but they use 8 bits /
byte, and cookies allow only a subset.

HTTP/1.x headers, and consequently document.cookie, must support all 8-bit
encodings. See RFC 1945, sections 4.2 and 2.2, and RFC 2616, ibid.


PointedEars
 
B

Bart Van der Donck

optimistx said:
If one would like to store in the user's local computer (= where the browser
is) some more data than the about 4 kilobytes the cookie can take, what to
do?

One possibility could be to split your data into multiple cookies:

| Both Internet Explorer and Netscape conform to the RFC 2109
| limitations on your total cookie count to 300 (this includes a
| limit of 20 cookies per individual domain) [*].

I don't think this is the best strategy, but it should give you up to
80K without problems.
The word 'storage' was mentioned lately, but does it store during one
session only?

There are persistent and non-persistent cookies. If the cookie is non-
persistent, it is deleted when the browser closes. If it is
persistent, it's kept until the given expiration date.
(Why not to store in the server? Yes, that is possible, but in this case I
would try to test the limits of javascript in the local computer... I love
javascript, just now, at least).

One idea is to pack data e.g. with LZH- algorithms, but they use 8 bits /
byte, and cookies allow only a subset. Allowed characters could be created
from the LZH- output bitstring (e.g. by picking 6 bits at a time, or perhaps
7), but this would probably be a bit messy. I could not with a 2 minute
search find an LZH- packer written in javascript, but there might be.
In this application some users might always be satisfied with the unpacked 4
kilobyte data, but some would prefer more.

Any ideas, more elegant perhaps?

Flash is widely supported and knows Local Shared Objects up to 100 KB
[**]. Or maybe you could save the data in a file on the server
(yourdomain.com/writablemap/random123.htm) and store that URI in a
cookie. Java and Active-X plugins also can save data at the client,
albeit mostly with a security warning.

[*] http://www.cookiecentral.com/faq/
[**]http://en.wikipedia.org/wiki/Local_Shared_Object &&
http://www.adobe.com/support/flash/action_scripts/local_shared_object/

Hope this helps,
 
B

Bart Van der Donck

Thomas said:
HTTP/1.x headers, and consequently document.cookie, must support all 8-bit
encodings.  

HPPT headers do not support any encoding whatshowever; they are in
ASCII (7-bit, not 8-bit).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,252
Latest member
MeredithPl

Latest Threads

Top