Skip to content

Instantly share code, notes, and snippets.

@wmandai
Created January 4, 2014 12:11
Show Gist options
  • Save wmandai/8254829 to your computer and use it in GitHub Desktop.
Save wmandai/8254829 to your computer and use it in GitHub Desktop.
<?php
//check for referal links
function referal()
{
$CI =& get_instance();
$cookie_value_set = $CI->input->cookie('_tm_ref', TRUE) ? $CI->input->cookie('_tm_ref', TRUE) : '';
if ($CI->input->get('ref', TRUE) AND $cookie_value_set == '') {
// referred user so set cookie to ref=username
$cookie = array(
'name' => 'ref',
'value' => $CI->input->get('ref', TRUE),
'expire' => '7776000',
);
$CI->input->set_cookie($cookie);
return TRUE;
}elseif ($cookie_value_set == '') {
$cookie = array(
'name' => 'ref',
'value' => 'sso',
'expire' => '15552000',
);
$CI->input->set_cookie($cookie);
return TRUE;
}elseif ($cookie_value_set != '') {
//already referred so ignore
return TRUE;
}else{
return TRUE;
}
}
//end of hooks file
@RobbiNespu
Copy link

@wmandai, why use webhook? and for referral system.. which one between using cookies or session are better option?
I assume ref link as website.com/r/uid, how to accomplish this? Any guide for me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment