I have this static function as part of a class.
For some reason ib_analytics_cf7_action
is set correctly, but ib_analytics_cf7_name
is not.
Can anyone see a reason for this?
public static function insert_contact_form_submit_tracking ($contact_form, $result, $echo=true) {
//I have confirmed the value exists and is a string
setcookie('ib_analytics_cf7_name', $contact_form->title());
switch ($result['status']) {
case 'validation_failed':
setcookie('ib_analytics_cf7_action', 'validation_failed');
break;
case 'spam':
setcookie('ib_analytics_cf7_action', 'spam');
break;
case 'mail_sent':
setcookie('ib_analytics_cf7_action', 'mail_sent');
break;
case 'mail_failed':
setcookie('ib_analytics_cf7_action', 'mail_failed');
break;
default :
return;
}
/*some debugging lines*/
return;
}
Given this less information it's impossible to really answer but it's probably just that the none of the cases are true and the control goes over to the default block.
EDIT:
Sorry for misunderstanding your question, one important thing you'll have to remember is that there shouldn't be any output before setting a cookie so make sure that you haven't print or echoed anything, also make sure that there aren't any whitespaces outside of your PHP tags.. That should fix it...