Page 1 of 1

Sending cookies on HTTP headers

Posted: Sun Dec 22, 2024 5:32 am
by siam00
We will write the code in PHP and add it to the plugin
Remember, I showed you how to create a WordPress plugin quickly. You can add code to your plugin.

Also go further by discovering how to set, get, and australian whatsapp number delete cookies in WordPress

Image

How cookies are created
To create Cookies in WordPress, you must define the value you want to add to the Cookie. In the following example, we will save the username, you will need to add the following code section in your plugin:

<?php

add_action( 'init', 'setting_my_first_cookie' );

function setting_my_first_cookie() {
setcookie( $v_username, $v_value, 30 * DAYS_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );
}