Index: referral.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/referral/referral.module,v
retrieving revision 1.16.2.5
diff -u -p -r1.16.2.5 referral.module
--- referral.module	26 Nov 2008 20:03:41 -0000	1.16.2.5
+++ referral.module	27 Nov 2008 17:58:58 -0000
@@ -231,6 +231,17 @@ function referral_user($op, $array = NUL
           '#value' => l(t('Register to this site using my referral link'), $link),
           '#type' => 'user_profile_item',
           );
+
+        // Set the cookie if user visits user profile page
+        $cookie = array(
+          'uid'      => arg(1),
+          'timstamp' => time(),
+          'ip'       => ip_address(),
+          'referer'  => $_SERVER['HTTP_REFERER'],
+        );
+
+        setcookie(REFERRAL_COOKIE, serialize($cookie), time() + 86400, '/');
+
       }
 
       if ($referrals) {
