2016-03-31 81 views
0

在註銷過程的平均時間內遇到PHP錯誤。登錄&註銷過程它仍然工作正常!但是當我註銷系統時顯示錯誤! 嚴重性:警告 消息:cookie名稱不能爲空 文件名:核心/ Input.php 行號:286Codeigniter消息:Cookie名稱不能爲空

這裏是我的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

setcookie($ prefix,$ name,$ value,$ expire,$ path,$ domain,$ secure);被稱爲內部功能? –

+0

是的,setcookie在函數內被調用。 –

回答

1

注:

  • 只需要名稱和值。要刪除cookie,將其設置爲過期空白。
  • 過期以秒爲單位設置,它將被添加到當前時間。不要包含時間,而只需要從現在起您希望cookie有效的秒數。如果過期設置爲零,則只有在瀏覽器處於打開狀態時,cookie纔會持續。
  • 對於整個網站的Cookie,不論你的網站是如何要求的,您的網址添加到開始一段域,就像這樣:。你的-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); 
相關問題