[eluser]SomeFunkyDude[/eluser]
I tried making a controller called "cookie" that sets a cookie in the constructor, then making a simple page2() segment that displays whether the cookie was set or not, but the cookie state keeps returning FALSE
Code:
<?php
class Cookie extends Controller {
function Cookie()
{
parent::Controller();
$this->load->helper('cookie');
$cookie = array(
'name' => 'cookie_name',
'value' => 'w00t!',
'expire' => '1000000',
'domain' => '.localhost',
'path' => '/',
'prefix' => 'myprefix_',
);
set_cookie($cookie);
}
function page1()
{
echo "<p>This is page 1!</p>";
echo '<a href="page2">Page 2</a>';
}
function page2()
{
echo "<p>This is page 2!</p>";
if (get_cookie('myprefix_cookie_name') === TRUE)
{
echo "<p>Cookie is set</p>";
} else {
echo "<p>Cookie not set</p>";
}
echo '<a href="page1">Page 1</a>';
}
}
?>