<!DOCTYPE HTML>
<html>
<head>
<script> function setcookie(a,b,c) {if(c){var d = new Date();d.setTime(d.getTime()+c);}if(a && b) document.cookie = a+'='+b+';path=/'+(c ? '; expires='+d.toUTCString() : '');else return false;}
function getcookie(a) {var b = new RegExp(a+'=([^;]){1,}');var c = b.exec(document.cookie);if(c) c = c[0].split('=');else return false;return c[1] ? c[1] : false;}
</script>
</head>
<body>
<input id="myinput" />
<script>
var input = document.getElementById('myinput');
var a = getcookie('dataForMyInput')
input.value = '';if(a)input.value=a;
input.oninput = input.onkeyup = input.onmouseup = function() {
var a = input.value;
var t = 1000*60*60*24*31;
if(!a){a=1;t=-10;} //Нет значений - стираем кук;
setcookie('dataForMyInput',a,t);
}
</script>
</body>
</html>