I want to replace my current functions of creating and reading cookie, and save it into the local storage instead. How can I replicate this for local storage instead?
function createCookie(name, value, days) {
    var c_date,
    c_name = name + "=" + value + ";",
    c_expi = "",
    c_domain = "domain=.domain.com;",
    c_path = "path=/";
    if (days > 0) {
        c_date = new Date();
        c_date.setTime(c_date.getTime() + (days * 24 * 60 * 60 * 1000));
        c_expi = "expires=" + c_date.toGMTString() + ";";
    }
    // create the cookie
    document.cookie = c_name + c_expi + c_domain + c_path;
}
    function readCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
        }
        return null;
    }
 
     
     
    