codeigniter - Not getting cookie value in codigniter -
here code set cookie
$cookie = array( 'name' => 'city', 'value' => $city, 'expire' => 86400 * 30, 'domain' => '.localhost', 'path' => '/', 'prefix' => 'picker_', ); $this->input->set_cookie($cookie) and loading cookie helper in constructor of controller.
my cookie set form 1 month , check in browser cookie set name 'city' , value = '10'. problem when retrieve value blank page nothing printing
here code of fetching value
echo $this->input->cookie('picker_city'); i try var_dump
var_dump($this->input->cookie('city', false)); it return false
what error.
you have load helper cookie first before using set_cookie
$this->load->helper('cookie'); and use set_cookie
if using cookies , better load in autoload.php in config folder.
in autoload array
$autoload['helper'] = array('cookie'); did load it?
note:
for local testing, leave domain value blank.
'domain' => '',
Comments
Post a Comment