For this question which of the session or cookie will do the desired job ?
I'm intrigued by the results after triggering a $_Session because I thought it only triggered when a visitor accessed the website.
In one day I had 378 accesses to my website or to the server that hosts my website. The whole world is trying to access my website while it is not online (12 countries). But that is not the problem at all! In less than 30 min there were 20 new visits from 6 different countries. Is it normal ?
Why are these accesses to my website counted when the statistics collected by my host only give me the reloads of pages that I perform (about 14)? Does the Host already filter bot ?
But that doesn't explain why I get about 200 results from my own ip address when I deleted all windows to my website between tonight and this morning . Also the increment is multiplied by two instead of being incremented by 1 .
How can I count the number of anonymous visitors every 24 hours who access my website? Can I limit the duration of a session to 10 seconds ? Does this restriction can filter bots ?
I try to store in one row of specific table :
- the auto-increment Id
- the unix time of day
- the number of visit incremented each time.
for now that's all I need.
Currently the main problem is the increment $_SESSION thats increment by 2 instead of 1 :
function StartSession(){
global $wpdb;
session_set_cookie_params(0, '/', '.website.com');
session_start();
if ( !isset( $_SESSION['visitor'] ) ) {
$countuser = $_SESSION['visitor'] = 1;
}else{
$countuser = ++$_SESSION['visitor'];
}
$users_analytics = $wpdb->prefix . 'antics_users';
$timeanonymesession = time();
$wpdb->insert(
$users_analytics,
array(
'datesession' => $timeanonymesession,
'totalusers' => $countuser
//'iploc' => $new_ip
)
);}
add_action('init', 'StartSession', 1);
If I use a cookie instead of a session, I think I'll have the same problem with incrementing, right?
Edit : in one day the *_SESSION have registered in database more than 1500 visit.
I don't understand why I have so many connection with $_SESSION whereas My Host registered only between 10 and 15 sessions by day (that normally corresponding to my reload page during developpement) ?