set cookie in wordpress to follow to referral link on membership script

I am trying to set a cookie in wordpress to track referrals.
The link will come in as domain.com/?ref_id and should follow through a link to domain.com/subfolder/?ref_id

I understand it should be very simple so please forgive my ignorance in the matter.
Thanks, ,

Read More

John.

Related posts

Leave a Reply

1 comment

  1. John,
    You want to do something similar to the following:

    $ref_id = $_GET['ref_id'];
    $expire=time()+60*60*24*30;
    setcookie("referral_id", $ref_id, $expire, '/', '.yourdomain.com');
    

    Don’t forget to sanitise the query string you are pulling in from $ref_id