Please try like this I created function that create cookie.
function deleteCookie(key) {
document.cookie = key + '="";expires=Thu, 01 Jan 1970 00:00:01 GMT;';
};
function setCookie(key, value) {
var expires = new Date();
expires.setTime(expires.getTime() + (60 * 1000));
document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
}
set cookie in click function.
$('.treeview a').on('click', function () {
setCookie('id', this.id);
});