如何重写在functions.php中创建的自定义cookie的值?

时间:2018-09-25 20:46:38

标签: javascript wordpress

我在functions.php中添加了自定义Cookie:

add_action( 'init', 'setCustomCookie' );

function setCustomCookie()
{
  setcookie('custom-cookie', true, time() + (86400 * 21), '/');
}

并且我需要在单击按钮后更改JS中的值:

$ = jQuery;

$(document).ready(function () {

    $('#against_more').click(function (evt) {
        event.preventDefault();

        var myCookie = getCookie("custom-cookie");

        // I tried setCookie and etc. nothing was succesfull

    })
});

可以这样做吗?

0 个答案:

没有答案