単純なカウンターを使用しても機能しません。半疑似コードで説明しようとします
$(document).ready(function(){
if(isPageLoadCookiePresent){
//this is a page load
setPageLoadCookie();
}else{
//this is a page refresh
}
});
また、Cookieを設定する代わりに、HTML5 WebストレージAPIを使用することもできます。
saveButton.addEventListener('click', function() {
window.localStorage.setItem('value', area.value);
window.localStorage.setItem('timestamp', (new Date()).getTime());
}, false);
textarea.value = window.localStorage.getItem('value');
Taken from here