Im creating a visit/page views counter with ajax,jquery and php, I have been reading a few articles that recommend the use of nonces for data manipulation through ajax, however i am not sure if i need to integrate the use of nonces for my simple counter?
my code looks somewhat like this;
jquery
jQuery.ajax({
type: 'POST',
url: ajaxurl,
data: {action: 'countHits', status: 'true'},
});
php
//ajax functions
add_action('wp_ajax_countHits', 'countHits');
add_action('wp_ajax_nopriv_countHits', 'countHits');
function countHits() {
if($_POST['status'] != "") {
$status= $_POST['status'];
if(!isset($_COOKIE['UNIQUEUSER'] && $status == 'true'){
$uniqueUser= get_option('stats');
$uniqueUser['uniqueUser']+=1;
update_option('stats', $uniqueUser);
}
die();
}
So as you can see it is very simple, do I need to use nonces for each ajax request?(i have two separate request in my jquery which return variables one for false one for true) furthermore, if I wanted to implement nonces how would i go about doing that?