same localStorage for http and https?

google-chrome, google-chrome-extension, html, javascript, local-storage

Solution

If all you need is store time spent on the site in localStorage then you don't need to solve this http/https problem. Extensions have their own isolated localStorage that you can access anytime anywhere, so just store your data there.

You can access this localStorage only from a background page, so from a content script you will need to send a request to a background page first and then work with localStorage there:

content_script.js:

chrome.extension.sendRequest({do: "save", value: "some_value"});

background.html:

chrome.extension.onRequest.addListener(function(request) {
    if(request.do == "save") {
        localStorage["param"] = request.value;
    } 
});

Problem

i'm looking for a way to use the same localStorage (or similar) for both `http:// example .com` and `https:// example .com` according to this, that's not possible using localStorage. there doesn't seem to be a `globalStorage` for chrome though. i'm doing this for a chrome extension, so using cookies is not an option and compatibility with other browsers is not needed. any ideas?

Original source

Related problems