From example, I want to pass $.cookie('article_id')
to PHP.
PHP provides a global variable called $_COOKIE
. This is an array with all the clients' cookies.
Use the Ajax of jQuery to send the cookie from client side to server side.
Basic syntax is:
$.ajax({
url: 'your php page URL',
type: 'POST',
dataType: 'html',
data: {data: $.cookie('article_id')},
success: function (returnData) {
//do what ever you want on success
},
});
OR
you can directly access the cookies from PHP by useing $_COOKIE
global variable.