<script>
var store = {
open : function(){
if("sessionStorage" in window)
return sessionStorage.getItem('count');
else
return /count=([^;]+);/.exec(document.cookie)[1];
},
save : function(value){
if("sessionStorage" in window)
sessionStorage.setItem('count', value);
else
document.cookie = "count=" + value;
}
};
var count = store.open();
count = count && isFinite(count) ? parseInt(count):0;
document.write('Вы посетитель № '+count);
count += 1;
store.save(count);
</script>