Re: Local Storage Not Retaining Data Between Local Browser Sessions

On Mon, Nov 29, 2010 at 2:03 PM, Jonas Sicking <jonas@sicking.cc> wrote:
> On Mon, Nov 29, 2010 at 1:55 PM, Adam Barth <w3c@adambarth.com> wrote:
>> On Sun, Nov 28, 2010 at 10:11 PM, Jonas Sicking <jonas@sicking.cc> wrote:
>>> On Sun, Nov 28, 2010 at 11:25 AM, Ronald Lane <rlane6013@verizon.net> wrote:
>>>> We would like to develop a system (javascript) to run on a local browser. We
>>>> would like to make use of local storage however in testing this out we see
>>>> that when running the app from a server local storage works fine but when
>>>> running the app locally it fails to retain the data between sessions.
>>>>
>>>> Is this an intended function?
>>>
>>> This is really a problem with the file: protocol rather than a problem
>>> with localStorage. localStorage works on the basis of origin, a
>>> concept which is defined for protocols like http: and https:, however
>>> I believe so far has not been defined for file:. I'd recommend talking
>>> with the IETF, though I wouldn't get my hopes up as it's really a very
>>> hard problem to solve unfortunately.
>>
>> Yeah, we've basically punted on the origin of file URLs in IETF-land.
>
> The only decent solution I've been able to think of is to make it
> possible to configure a browser to tell it that a given local
> directory constitutes a "site" and that all files in that directory
> (and its sub-directories) are same-origin.

Yeah.  One clean why to do that is to create a new scheme, say
local-origin, and map in parts of the file system under different host
names.  For example:

local-origin://foobarbaz/css/main.css

would internally be resolved to
file:///home/abarth/Projects/FunWithCSS/css/main.css.

The idea is that everything in the FunWithCSS folder would be mapped
into the local-origin://foobarbaz origin, safely isolated from the
rest of the filesystem.

> A solution like that is likely out of scope for IETF. The best way to
> pursue a solution like that is to start talking to individual browser
> vendors directly.

We've actually implemented the above in Chrome, it's just not really
advertised in the IU.

Adam

Received on Saturday, 11 December 2010 19:25:32 UTC