0
You’re making this mistake in several parts of my homepage. But I don’t know how to fix it. Follow the error and the corresponding code line.
Notice: Undefined index: identifier in /home3/.../helpers-general.php on line 1112
Part of code containing line 1112:
function foodbakery_set_transient_obj($transient_variable, $data_string, $time = 12) {
if ( !isset($_COOKIE['identifier']) || $_COOKIE['identifier'] == '' ) {
setcookie('identifier', uniqid(), time() + (86400 * 30), "/"); // 86400 = 1 day
}
$result = '';
$identifier = '';
$identifier = $_COOKIE['identifier']; // <==== linha 1112
$time_string = $time * HOUR_IN_SECONDS;
if ( $data_string != '' ) {
$result = set_transient($identifier . $transient_variable, $data_string, $time_string);
}
return $result;
}
It already has something like this just below.
if ( ! function_exists('foodbakery_get_transient_obj') ) {

 function foodbakery_get_transient_obj($transient_variable) {
 //$data_string = get_transient( $transient_variable );
 $identifier = uniqid();
 if ( isset($_COOKIE['identifier']) ) {
 $identifier = $_COOKIE['identifier'];
 }
 if ( false === ( $data_string = get_transient($identifier . $transient_variable) ) ) {
 return false;
 } else {
 return $data_string;
 }
 }

}
– Mauricio Santos
@So with that, I can assume that you understand what’s wrong and you’ve solved the problem?
– Woss
So, Anderson, that code was already there, it doesn’t include anything. I still don’t understand the reason for the error, because when I enter the Adm user the error does not appear. But on other accounts or computers the error keeps appearing;
– Mauricio Santos
But it was "there" in a completely different function than the one you put in the question. The error is in the function
foodbakery_set_transient_obj
and this logic was only used infoodbakery_get_transient_obj
. Did you read the full answer? Did you search for the above HTTP headers? What did you not understand?– Woss
It has nothing to do with one function. I don’t understand exactly why the error is because I don’t know PHP, so I basically don’t know what’s going on there. But for some reason the error stopped showing up. Thanks for the answer.
– Mauricio Santos
@Mauriciosantos But the error is not PHP, it is HTTP. PHP, in this case, was just the tool to manage HTTP. If you are working with web and have no idea what I said in the reply, I strongly recommend that you stop everything and study the HTTP protocol.
– Woss
Got it, I’ll do it. Thanks for the tip.
– Mauricio Santos