1

CodeIgnitier で Cookie を設定しようとしていますが、うまくいきません。私は解決策を探していましたが、Stackoverflow にもいくつかの投稿がありましたが、実際に問題を解決したものはありませんでした。

コードは次のとおりです。

$this->load->helper('cookie');
set_cookie('username',$this->input->post('username'));

実行後に Cookie が設定されませんでした。

間違った答えを避けるために: 'secure' は構成ファイルで FALSE に設定されており、他のすべてもデフォルトとして設定されています。ブラウザによると、Cookie が設定されていませんでした。Codeignitier ネイティブ Cookie のみ - ci_session がそこにリストされます。

4

1 に答える 1

3

次のように配列を介して設定します。

$cookie = array(
    'name' => 'username',
    'value' => $this->input->post('username'),
    'expire' => '0', // expiration time 0 is until browser closes, set to large number for 'remember me' cookie
    'domain' => '.mysite.com', // set this to the domain the cookie will be under with a leading .
    'path' => '/',
    'prefix' => '',
    'secure' => FALSE
); 
$this->input->set_cookie($cookie); 
于 2013-02-11T21:31:22.437 に答える