I want to update cookie value after checking the specific condition in javascript function. After checking it I am calling one php function(cookie updatingg) from javascript function. Everytime when I refresh the page my cookie value get updated with +1 in short it's not satisfying condition.
My code is:
JavaScript Function:
<script type="text/javascript">
function on_call_php(){
var result="<?php php_func();?>";
alert(result);
return false;
}
Php Function Code:
<?php
function php_func(){
setcookie("correct", $_COOKIE["correct"]+1, time() + (86400 * 30), "/");
echo "hello";
}
?>