Aravinth E Aravinth E - 15 days ago 9
jQuery Question

how to pass jquery variable into php file using cookies

i used for this code pass jquery variable data into php file but does not worked on this code. does not get cookie value on php file.... how to solve this problem...

my jquery code

$(document).ready(function(){
var data = 1;
ownerEdit(data);
});

function ownerEdit(id) {
document.cookie = 'id=id';
}


i was passed the cookie value for php file...

my php code

$id = $_COOKIE['editid'];
print_r($id);


does not get cookie value on php file....

Answer

Maybe like this

function ownerEdit(id) {
    document.cookie = 'editid = ' + id;
}