[eluser]gh0st[/eluser]
I am trying to figure out how to get cookies to work with CI, but they do not appear to work,
I am wanting to store a value for later use.
I am doing a basic example:
Code:
class Test2 extends Controller
{
function Test2()
{
parent::Controller();
$this->output->enable_profiler(TRUE);
}
function index()
{
$this->load->helper('cookie');
$cookie = array(
'name' => 'testcookie',
'value' => 'hello world',
'expire' => '86500',
'domain' => '.localhost',
'prefix' => 'my_'
);
print set_cookie($cookie);
redirect("/test2/test_my_cookie");
exit;
} // end function
function test_my_cookie()
{
print __FUNCTION__;
print '<p><pre>';
print_r($_COOKIE);
print '</pre></p>';
print get_cookie('my_testcookie');
} // end function
} // end class
The cookie values are always empty. I have tested a PHP cookie (hard-coded) and this works fine, but the CI ones don't -- why not?
How do I get cookies to work?