fenix_63,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<script>
document.addEventListener('DOMContentLoaded', function() {
document.querySelector('.ref').addEventListener('click',
function() {
var date = new Date(new Date().getTime() + 24 * 60 * 60 * 1000), // сутки
hostname = window.location.hostname;
if(hostname) document.cookie = "referer="+hostname+"; path=/; expires=" + date.toUTCString();
});
document.querySelector('.info').innerHTML = document.cookie
console.log(document.cookie);
});
</script>
</head>
<body>
<div class="info"></div>
<a href="site2.ru" class="ref">Ссылка</a>
</body>
</html>