![]() |
Saving session data - 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: Saving session data (/showthread.php?tid=4465) |
Saving session data - El Forum - 11-26-2007 [eluser]dgriffter[/eluser] Hi, I'm saving a session variable in a view file using the following code: $this->session->set_userdata('message', 'bling bling bling'); I then try to access the saved message later in the same view file like so: <p><?php $this->session->userdata('message'); ?></p> I'm getting an empty paragraph... can anyone please help? Thanking you kindly, Dgriffter Saving session data - El Forum - 11-26-2007 [eluser]gtech[/eluser] I don't think the <?php tags will display content you need the <?= tags eg Code: <p><?= $this->session->userdata('message'); ?></p> the php tags will execute php code but not display it. Saving session data - El Forum - 11-26-2007 [eluser]wakextreme[/eluser] [quote author="gtech" date="1196139256"]I don't think the <?php tags will display content you need the <?= tags eg Code: <p><?= $this->session->userdata('message'); ?></p> the php tags will execute php code but not display it.[/quote] gtech is right you either need to do as he suggested and use the short tags or you can add echo. Code: <p><?php echo $this->session->userdata('message'); ?></p> Saving session data - El Forum - 11-26-2007 [eluser]dgriffter[/eluser] The echo treatment surely worked.... thank you, you guys/girls are fantastic. Very much appreciated, Dgriffter |