Implementation to count page visits of unique visitors based on a cookie

Here’s a minimum working example… (note: this is untested code.) add_action(‘init’, ‘custom_rsvp_handler’); function custom_rsvp_handler() { // for singular posts only // (could also check for event post type here) if (!is_singular()) {return;} // set cookie expiry length (eg. 28 days) $cookielength = time()+(60*60*24*28); // set a cookie key based on post ID global $post; $cookiekey … Read more

When ever wordpress home page refreshes the code is not reading the cookie as set anymore

You cannot use setcookie() after you’ve already started outputting stuff to the body (in this case your javascript-debugging, but possibly something else outside that function). Are you suppressing PHP warnings? It should complain with “Cannot send headers; headers already sent” and tell you where the output was started. To get rid of the problem regarding … Read more

how to remember specific action/event for current user?

According to the documentation there are 3 Polylang functions that can help you here : The first to “remember” the user language. pll_current_language // Returns the current language pll_current_language( $value ); // ‘$value’ => (optional) either ‘name’ or ‘locale’ or ‘slug’, defaults to ‘slug’ returns either the full name, or the WordPress locale (just as … Read more

WordPress delete cookie

You can delete all cookies that belong to your domain. See the answer to this here: https://stackoverflow.com/questions/2310558/how-to-delete-all-cookies-of-my-website-in-php . You would have to build a form with a button to that (on submit) would call the function that deleted the cookies that belong to your domain. I don’t think you can delete cookies that don’t belong … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)