Flashdata boolean gets converted between requests - 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: Flashdata boolean gets converted between requests (/showthread.php?tid=18581) |
Flashdata boolean gets converted between requests - El Forum - 05-11-2009 [eluser]mawe[/eluser] Hi all! The topic pretty much says it all. I have this in a controller: Code: function delete($news_id) In the archive view I had this: Code: <?php if ($this->session->flashdata('deleted')): ?> The inner if (the one that checks for TRUE) doesn't work. I examined the session and the flashdata item is actually '1', a string, not boolean TRUE. Is this expected behaviour? Flashdata boolean gets converted between requests - El Forum - 05-11-2009 [eluser]Dam1an[/eluser] I think this is expected When the session data is stored, its serialized, so it all becomes a long String When it gets deserialized at the other end, I'm asuming it was stored as '1', so it probably stays as that Flashdata boolean gets converted between requests - El Forum - 05-11-2009 [eluser]mawe[/eluser] Thanks for the answer, but this is only correct for the first part. Just tested this on my machine. Though it really gets serialized to a string, unserialize handles data types properly: Code: C:\Users\MatiPati\Desktop>type test.php Flashdata boolean gets converted between requests - El Forum - 05-20-2009 [eluser]benoa[/eluser] What if you do it this way? Code: function delete($news_id) And in the view: Code: <?php if (isset($this->session->flashdata('deleted'))): ?> Maybe the synthax is broken somewhere (no code highlighting in the reply textarea)... But I hope this can help! |