![]() |
Help storing and calling a cookie correctly - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Help storing and calling a cookie correctly (/showthread.php?tid=10910) |
Help storing and calling a cookie correctly - El Forum - 08-18-2008 [eluser]Chad Crowell[/eluser] OK I am having users perform a search, the results of which are shown on the resulting view file, and then the search form is shown again on the search results view alongside the search results. I want to populate the search form with the terms they just searched for, and what i did is, in the controller that grabs the search results, I placed the search terms in a cookie, then I grab that value when the view is shown and show it in the form field. This is all working fine, but its one step behind. Let me exampleate: I search for verizon I see a new page with search results for verizon On that same page, in the "search again" form field, I see nothing I search for bellsouth I see a new page with search results for bellsouth On that same page, in the "search again" form field, I see "verizon" So it appears that in the controller, even though I delete and then reset the cookie before calling the search results view, which would seem to me is the right way to do it, the cookie is still containing the previous value. Any ideas? Help storing and calling a cookie correctly - El Forum - 08-18-2008 [eluser]erik.brannstrom[/eluser] Why do you use cookies to store the value? I assume the search is performed using a standard form? If so, the value of your search is right in the $_POST variable. Just add something like Code: <input type="text" name="query" value="<?= isset($_POST['query']) ? $_POST['query'] : '' ?>" /> Help storing and calling a cookie correctly - El Forum - 08-18-2008 [eluser]Chad Crowell[/eluser] Holy crap. Sometimes i'm really not an idiot. I swear. Thanks Erik |