Home

Browser persistence.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="jquery.cookie.js"></script> <input id="inputCookie"></input> <button onclick="saveCookie();" >Save</button>
let saveCookie = function() { let cookieValue = document.getElementById( 'inputCookie' ).value; $.cookie( 'learn', cookieValue ); location.reload(); } // load cookie document.getElementById( 'inputCookie' ).value = $.cookie( 'learn' );

Local storage.

<input id="inputLocalStorage"></input> <button onclick="saveLocalStorage();" >Save</button>
let saveLocalStorage = function() { let value = document.getElementById( 'inputLocalStorage' ).value; window.localStorage.setItem( 'learn', value ); location.reload(); } // load from local storage let value = window.localStorage.getItem( 'learn' ); document.getElementById( 'inputLocalStorage' ).value = value;

Session storage.

Like localStorage, but:

JSON serialization.

let json = { string: 'Hello World!', age: 100, date: '2017-06-17', checked: true, array: [ 1, 2, 3 ], object: { name: 'Hu?', size: 10 } }; let serialized = JSON.stringify( json ); let parsed = JSON.parse( serialized ); let el = document.getElementById( 'parsedOutput' ); el.innerHTML = JSON.stringify( parsed, null, 2 );