Unable to store data locally

i can’t retrieve locallystore veriable, kindly help… thanks in advance,

var testObject = { ‘one’: 1, ‘two’: 2, ‘three’: 3 };

                // Put the object into storage

                localStorage.setItem('testObject', JSON.stringify(testObject));

                // Retrieve the object from storage

                var retrievedObject = localStorage.getItem('testObject');

                 console.log('retrievedObject: ', JSON.parse(retrievedObject));

                alert('retrievedObject: ', JSON.parse(retrievedObject));

This is a simple example. Copie and test if works.

Also i use window.localstorage.set…

I cannot get the localStorage.getItem(‘user_name’); in other pages,…kindly helpout

This is a working example i use and work.

// Save data
    var stringData = { "id": "10", "item2": "something", "item3": "100" };
    window.localStorage.setItem("keyData", JSON.stringify(stringData));

// Get data
    var newString = JSON.parse(window.localStorage.getItem('keyData'));

    console.log(newString);

I have the solution, linking jquery to the project, solved the problem