![]() |
Can't set cookie - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Can't set cookie (/showthread.php?tid=55430) |
Can't set cookie - El Forum - 10-26-2012 [eluser]veledrom[/eluser] Hi, Code below never sets a cookie! Do I miss anything? Thanks VIEW Code: <a href="<?php echo site_url('language/set_language/en'); ?>">English</a> CONTROLLER Code: class Language extends CI_Controller Can't set cookie - El Forum - 10-26-2012 [eluser]veledrom[/eluser] Anyone there? Or anyone understand cookies??? Can't set cookie - El Forum - 10-26-2012 [eluser]CroNiX[/eluser] You can't read a cookie until the next request because it hasn't been written yet. It gets set when the whole page is sent as it gets transmitted along with the headers and not immediately when you call set_cookie(). The data is meant to be used in subsequent requests, not the current one. http://php.net/manual/en/function.setcookie.php Can't set cookie - El Forum - 10-26-2012 [eluser]CroNiX[/eluser] Also, I assume you're using SSL on the server since you are using a "secure" cookie. Can't set cookie - El Forum - 10-26-2012 [eluser]veledrom[/eluser] Thanks for replying. I've changed example and added redirect(); and added another function to read the cookie but this example doesn't work either. How do I modify this example make it work? Sorry for being pain. VIEW Code: <p> CONTROLLER Code: class Welcome extends CI_Controller |