How to get cookies to work?

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:

class Test2 extends Controller

    function Test2()

    function index()
        $cookie = array(
               'name'   => 'testcookie',
               'value'  => 'hello world',
               'expire' => '86500',
               'domain' => '.localhost',
               'prefix' => 'my_'
        print set_cookie($cookie);
    } // end function
    function test_my_cookie()
        print __FUNCTION__;
        print '<p><pre>';
        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?

As a test, try setting domain => false in the code you posted and see if that works.

Check out:

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.