当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - How to remove cookies error Notice: Undefined index on PHP

问题描述:

This question already has an answer here:

  • PHP: “Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset”

    19 answers

网友答案:

You should first check if your element exists in your array:

if (array_key_exists('aktifko',$_COOKIE) AND $_COOKIE['aktifko'] != 'XXX')

With your current code, you are checking the value of this element in the cookie array. But if it's the first time for the user, this element won't exist in the array. So you have to check if the key already exists before checking its value.

分享给朋友:
您可能感兴趣的文章:
随机阅读: