setcookie()在jquery get()请求

My problem is that the cookie won't set. I tried removing the / in the setcookie function but it changes nothing. Also, the path is correct. If I echo something after the setcookie line, and I alert the data in the javascript function, the echo works.

index.php:

$.get('inserts/queries?q=1', function(data) {
    undisplay('cookiesMenu');
});

inserts/queries.php:

if ($_GET['q'] == 1)
{
    setcookie('cookies', '', time() + 3600 * 24 * 365, '/');
}

Thanks to @carloliwanag ! Didn't know creating a cookie in JS was possible. It did the trick!

document.cookie = "cookies=; expires=Sun, 31 Dec 2017 12:00:00 UTC";