I used jquery cookie plugin (https://github.com/carhartl/jquery-cookie)
$(function(){
if($.cookie){
//By default, if no cookie, just display.
$("#marketing-message-global").toggle(!(!!$.cookie("toggle-state")) || $.cookie("toggle-state") === 'true');
}
$('#hide-marketing-message-btn').on('click', function(){
$("#marketing-message-global").toggle();
//Save the value to the cookie for 1 day; and cookie domain is whole site, if ignore "path", it will save this cookie for current page only;
$.cookie("toggle-state", $("#marketing-message-global").is(':visible'), {expires: 1, path:'/'});
});
});