gpt4 book ai didi

php - 为什么我在 Codeigniter 上收到错误 'Call to undefined function delete_cookie ()'?

转载 作者:行者123 更新时间:2023-12-02 00:45:46 25 4
gpt4 key购买 nike

我认为我运行的代码是正确的,但运行中的某个时刻甚至出现错误'Call to undefined function delete_cookie ()'

请指正:)

在 Controller Product_Ref.php 中

public function index()
{
$ref = $this->input->get('id');
$getIdOrder = $this->product_model->getIdOrder($ref);
if ($getIdOrder) {
$this->load->helper('cookie');
$cookie = array(
'name' => 'refProductcookie',
'value' => $ref,
'expire' => '43200'
);
$this->input->set_cookie($cookie);
echo get_cookie('refProductcookie').'<br>';
}else {
echo "Sorry this product has not been registered yet";
delete_cookie('refProductcookie');
}
}

最佳答案

您需要为您的两个 if-else 加载助手 cookie:

// load BEFORE `if`
$this->load->helper('cookie');
if ($getIdOrder) {
$cookie = array(
'name' => 'refProductcookie',
'value' => $ref,
'expire' => '43200'
);
$this->input->set_cookie($cookie);
echo get_cookie('refProductcookie').'<br>';
}else {
echo "Sorry this product has not been registered yet";
delete_cookie('refProductcookie');
}

关于php - 为什么我在 Codeigniter 上收到错误 'Call to undefined function delete_cookie ()'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44018198/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com