Hoa set cookie - PhucVM2019/frontEnd GitHub Wiki
(function () {
function getData(){
//set
debugger;
function setCookie(name, data) {
console.log('name: '+name+'; data: '+ data);
var expDate = new Date();
expDate.setTime(expDate.getTime() + 30 * 24 * 60 * 60 *1000);
document.cookie = name + '=' + data + ';expires=' + expDate.toGMTString() + 'path=/';
}
//get
function getCookie(name) {
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : undefined;
}
//get text select
$('#debitAccount1').change(function(){
var DataOption = $('#debitAccount1').has('option').val();
alert("Welcome again " + DataOption);
//set cookie theo name
setCookie("dateCookies",conceptName);
//call cookie theo name
var dataSet = getCookie("dateCookies");
if($('#debitAccount1').has('option').val() == null || $('#debitAccount1').has('option').val() == "" ) {
conceptName = $('#debitAccount1').find(":selected").text(dataSet);
}
alert("Welcome again " + conceptName);
})
}
function main(){
getData();
};
main();
})();