Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7911439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:14:58+00:00 2026-06-03T13:14:58+00:00

I need to store some data client side and this data is too large

  • 0

I need to store some data client side and this data is too large to store it in a cookie. LocalStorage seemed like the perfect way of doing this but the thing is that the website that i will be using this has some parts that work on https and others with just http and as local storage can’t access data from https that you set with http this doesn’t seem like a viable solution anymore.

Any idea if there is any solution to this? Any other alternatives?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:15:01+00:00Added an answer on June 3, 2026 at 1:15 pm

    Store all data on one domain, e.g. https://my.domain.org/.

    • On https protocols, simply use localStorage.setItem('key', 'value') to save the data.
    • On http protocols, embed a https frame, and use postMessage to save the data:

    Demo: http://jsfiddle.net/gK7ce/4/ (with the helper page being located at http://jsfiddle.net/gK7ce/3/).

    // Script at https://my.domain.org/postMessage
    window.addEventListener('message', function(event) {
        // Domain restriction (to not leak variables to any page..)
        if (event.origin == 'http://my.domain.org' ||
            event.origin == 'https://my.domain.org') {
            var data = JSON.parse(event.data);
            if ('setItem' in data) {
                localStorage.setItem(data.setItem, data.value);
            } else if ('getItem' in data) {
                var gotItem = localStorage.getItem(data.getItem);
                // See below
                event.source.postMessage(
                    '#localStorage#' + data.identifier + 
                    (gotItem === null ? 'null#' : '#' + gotItem),
                    event.origin
                );
            } else if ('removeItem' in data) {
                localStorage.removeItem(data.removeItem);
            }
        }
    }, false);
    

    On the http(s) page, the frame can be embedded as follows (replace https://my.mydomain.com with the actual URL. Note that you can simply get a reference to the frame, and use the src attribute):

    <iframe name="myPostMessage" src="https://my.domain.org/postMessage" style="display:none;"></iframe>
    // Example: Set the data
    function LSsetItem(key, value) {
        var obj = {
            setItem: key,
            value: value
        };
        frames['myPostMessage'].postMessage(JSON.stringify(obj), 'https://my.domain.com');
    }
    LSsetItem('key', 'value');
    

    Note that the method is asynchronous, because of postMessage. An implementation of the getItem method has to be implemented differently:

    var callbacks = {};
    window.addEventListener('message', function(event) {
        if (event.source === frames['myPostMessage']) {
            var data = /^#localStorage#(\d+)(null)?#([\S\s]*)/.exec(event.data);
            if (data) {
                if (callbacks[data[1]]) {
                    // null and "null" are distinguished by our pattern
                    callbacks[data[1]](data[2] === 'null' ? null : data[3]);
                }
                delete callbacks[data[1]];
            }
        }
    }, false);
    function LSgetItem(key, callback) {
        var identifier = new Date().getTime();
        var obj = {
            identifier: identifier,
            getItem: key
        };
        callbacks[identifier] = callback;
        frames['myPostMessage'].postMessage(JSON.stringify(obj), 'https://my.domain.com');
    }
    // Usage:
    LSgetItem('key', function(value) {
        console.log('Value: ' + value);
    });
    

    Note that each callback is stored in a hash. Each message also contains an identifier, so that the window which receives the message calls the correct corresponding callback.

    For completeness, here’s the LSremoveItem method:

    function LSremoveItem(key) {
        var obj = {
            removeItem: key
        };
        frames['myPostMessage'].postMessage(JSON.stringify(obj), 'https://my.domain.com');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data stored on client side which I need to fetch thru
How can a web application store a very large amount of data client-side? (I'm
I need to store some data in a Django model. These data are not
I usually use C++ stdlib map whenever I need to store some data associated
I need to store some sensitive data by encrypting it with atleast 128 bit
I want to store some data during my site viewing. Sometime i need to
I am trying to store some cryptographic data in couchdb. I need to store
I would like to store data temporarily on clientside. What is the best way
I need a mechanism for storing complex data structures created in client side javascript.
I need to store some simple properties in a file and access them from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.