Cookie with referral URL [closed]

You can do this as we do in PHP.
You can set cookie following way.

setcookie( 'cookie-name', 'cookie-value', 'cookie-expiration-time', 'cookie-path', 'cookie-domain', false );

For referral url, I made following code that you can use to set a cookie with name my-referral-cookie and time() + 3600 (1 hour from current time) is expiration time for cookie.

setcookie( 'my-referral-cookie', $_SERVER['HTTP_REFERER'], time() + 3600, COOKIEPATH, COOKIE_DOMAIN, false );

You can get the value of cookie like this.

echo $_COOKIE['my-referral-cookie'];

That’s it.