if(data.userId) {
$(“#logout_user”).click(function (e) {
e.preventDefault();
logOut(data.access_token,data.userId);
});
}
function logOut(token,tnoid){
var settings = {
“url”: ‘https://upi.thanhnien.vn/api/account/logout’,
“method”: “POST”,
“timeout”: 5000,
“headers”: {
“Authorization”:”Bearer “+token+””
},
};
if (token){
$.ajax(settings).done(function (response) {
if (response.success){
setCookie(“_ck_user”+tnoid, ”, 0);
setCookie(“my_tnoid”, ”, 0,’.thanhnien.vn’);
setCookie(“my_tnosso”, ”, 0,’.thanhnien.vn’);
location.reload();
}
});
}
}
}
});
function setCookie(c_name, value, exdays,domain=null) {
var exdate = new Date();
exdate.setMinutes(exdate.getMinutes() + exdays);
var c_value = escape(value) + ((exdays == null) ? “” : “; expires=” + exdate.toUTCString()) + ‘;path=/’;
if (domain!=null){
c_value=c_value+’;domain=’+domain;
}
document.cookie = c_name + “=” + c_value;
}
https://thanhnien.vn/ung-cuu-tau-ngu-dan-gap-nan-tren-vung-bien-quang-binh-185241122175617549.htm