Can't set cookie |
[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
[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
[eluser]CroNiX[/eluser]
Also, I assume you're using SSL on the server since you are using a "secure" cookie.
[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 |
Welcome Guest, Not a member yet? Register Sign In |