Created
January 4, 2014 12:11
-
-
Save wmandai/8254829 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@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?