Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Eazybright/956638f0a4df76861bd5260866dd0355 to your computer and use it in GitHub Desktop.
Save Eazybright/956638f0a4df76861bd5260866dd0355 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment