在注销过程的平均时间内遇到PHP错误。登录&注销过程它仍然正常工作!但是当我退出系统时它显示错误! 严重性:警告 消息:Cookie名称不能为空 文件名:core / Input.php 行号:286
这是我的Input.php set_cookie函数的代码:
function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
{
if (is_array($name))
{
// always leave 'name' in last place, as the loop will break otherwise, due to $$mill
foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'name') as $mill)
{
if (isset($name[$mill]))
{
$$mill = $name[$mill];
}
}
}
if ($prefix == '' AND config_mill('cookie_prefix') != '')
{
$prefix = config_mill('cookie_prefix');
}
if ($domain == '' AND config_mill('cookie_domain') != '')
{
$domain = config_mill('cookie_domain');
}
if ($path == '/' AND config_mill('cookie_path') != '/')
{
$path = config_mill('cookie_path');
}
if ($secure == FALSE AND config_mill('cookie_secure') != FALSE)
{
$secure = config_mill('cookie_secure');
}
if ( ! is_numeric($expire))
{
$expire = time() - 86500;
}
else
{
$expire = ($expire > 0) ? time() + $expire : 0;
}
setcookie($prefix.$name, $value, $expire, $path, $domain, $secure);
}
行号:286
setcookie($prefix.$name, $value, $expire, $path, $domain, $secure);
答案 0 :(得分:1)
注意:
对于网站范围的Cookie,无论您的网站是如何被请求的,请将您的网址添加到以某个句点开头的域中,如下所示:.your-domain.com
$cookie = array(
'name' => 'demo',
'value' => 'Hello i m cookies which saved in this broswer',
'expire' => '86500',
'domain' => 'yourdomain', // in localhost this should be null
'path' => '/',
'prefix' => 'myprefix_',
'secure' => TRUE );
$this->input->set_cookie($cookie);
离散参数
如果您愿意,可以通过使用单个参数传递数据来设置cookie:
$this->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure);