?>
_IN_SECONDS is provided by WordPress and contains the number of seconds in a day. You'll notice that this value is multiplied by 30, or nearly a month. The constant "COOKIEPATH" defines the path to your site, and "COOKIE_DOMAIN" is the domain name of your site.
Once the function is executed you will notice that the cookie is indeed added to the browser. Remember to match the values of $v_username and $v_value.
How to restore cookies
To retrieve the cookies created by us, we will use the $_COOKIE variable which is an associative array that contains all the cookies created by WordPress.
The identifier we will use is the one we defined australian whatsapp number
above on the $v_username value. See the code below:
Before passing the identifier to the global variable $_COOKIE, we must make sure that the identifier does not exist with the function "isset"
Discover 6 WordPress plugins perfect for ensuring GDPR compliance for your blog
How to Delete Cookies
Sometimes you need to delete Cookies from your website, especially when you no longer need the information. Take a look at the code below:
<?php
unset( $_COOKIE[$v_username] );
setcookie( $v_username, '', time() - ( 15 * 60 ) );
?>
In the previous code, we have used the function “set” to delete the values of the $_COOKIE array. In the case of expired cookies , we have changed the expiration date and passed an empty string to delete the cookie value.