CodeIgniter Forums
How would I put a session variable in to a form field value? - 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: How would I put a session variable in to a form field value? (/showthread.php?tid=48785)



How would I put a session variable in to a form field value? - El Forum - 01-28-2012

[eluser]trinic[/eluser]
This doesn't work

Code:
value="<? php echo $this->session->userdata('user_first_name') ?>"

Also, before it's asked, yes it's a session variable. Would it be easier to pull it from the database?


How would I put a session variable in to a form field value? - El Forum - 01-28-2012

[eluser]helmy[/eluser]
Set the session variable to a variable in the controller and pass it to the view. Then try echoing it.


How would I put a session variable in to a form field value? - El Forum - 01-28-2012

[eluser]limit[/eluser]

You have a space in your php tag, is that a typo? Also you can use $this->output->enable_profiler(TRUE); in your controller to view session data. Make sure you initialize the session class $this->load->library('session');