JSFiddle - React, Tailwind, and code Playground
HTML
<form name="myform">
<input type=text name=input1 value=""/>
</form>
JavaScript
function setCookie(key, value) {
var expires = new Date();
expires.setTime(expires.getTime() + (1 * 24 * 60 * 60 * 1000));
document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
}
function getCookie(key) {
var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
return keyValue ? keyValue[2] : null;
}
$(document).ready(function() {
setCookie("input1",'1');
alert(getCookie("input1"));
document.myform.input1.value = getCookie("input1");
});