[whatwg] Some likeness of DOM Session scope

Ian Hickson ian at hixie.ch
Wed Sep 7 14:57:59 PDT 2005

On Thu, 21 Apr 2005, Kornel Lesinski wrote:
> On Thu, 21 Apr 2005 14:07:45 +0100, Ian Hickson <ian at hixie.ch> wrote:
>> Anyone have any concrete proposals? :-)
> Persistent associative array that stores anything*, just like session 
> object in PHP and ASP.
> This might be called: document.localCookies

Is window.sessionStorage and window.globalStorage ok?

> Scope would be just like in HTTP cookies, but these wouldn't be sent to 
> the server and wouldn't have length limit.
> To store object:
> document.localCookies['key_name'].value = anything;
> To retrieve object:
> anything = document.localCookies['key_name'].value;

Yup, pretty much exactly that:

To store object:
window.sessionStorage['key_name'].value = anything;
To retrieve object:
anything = window.sessionStorage['key_name'].value;

> * only /Storable/ objects should be allowed. Storable objects are the 
> ones that implement "sleep" and "wake" methods that (un)serialize them. 
> That would be save/load XML for DOMNodes, toString/parseInt/etc for 
> basic types.

Not quite the way I defined it, but the idea is the same.

Thanks for the feedback, please let me know if the proposal is ok:

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list