CodeIgniter Forums
Can not set cookie in ci4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Can not set cookie in ci4 (/showthread.php?tid=75841)



Can not set cookie in ci4 - seunex - 03-22-2020

unable to set and get cookie in ci4
PHP Code:
if(! $this->response->hasCookie('test'))
        {
            $cookie = [
                    'name'   => 'test',
                    'value'  => 'The Value',
                    'expire' => '86500',
                    'path'   => '/',
                    'secure' => TRUE,
                    'httponly' => FALSE
            
];
            
            $show 
$this->response->setCookie($cookie);
            echo 'cookie set!';