i create a simple cookie with ajax method post, by a popup with a button, this button calls the ajax function.
the cookie is there, exists, but i can't read it inside wordpress by a shortcode or a function.
Ajax function
<script>
function cookieC(){
var v1="datacookie";
var param = {
"v1" : v1
};
$.ajax({
data: param,
url: 'cookie_create.php',
type: 'post',
beforeSend: function () {
},
success: function (response) {
alert('ok');
}
});
}
</script>
PHP cookie_create.php
$data = $_POST['v1'];
setcookie( 'namecookie', $data, time() + 3600);
Inside wordpress i try read it
Function.php or in the main file of a plugin.
if(isset($_COOKIE['namecookie']))
{
echo "All right";
}
else
{
echo "something is wrong";
}
no matter what I do, always prints else
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire