CodeIgniter Forums

Full Version: set_cookie() doesn't work with redirect()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
This is my code:

PHP Code:
namespace App\Controllers;
use 
CodeIgniter\Controller;

class 
Home extends Controller
{
    public function 
__construct()
 
 {
 
   helper(['cookie']);
 
 }
    public function 
page1()
    {
        
set_cookie('test''testvalue-'.time(), time() + 86400);
        return 
redirect()->to('page2');
    }
    public function 
page2()
    {
        echo 
get_cookie('test');
    }


Redirect is working but there is no 'test' cookie on page2. Please help.