Pain Posted November 13, 2012 Share Posted November 13, 2012 (edited) Hi there. I am trying to display a session variable on the page. However i am not sure if the code should be placed in the view or in the model? Also is this line of code written correctly? print_r $this->session->all_userdata() Thank you:) Edited November 13, 2012 by Pain Quote Link to comment https://forums.phpfreaks.com/topic/270651-codeigniter-session-display/ Share on other sites More sharing options...
Adam Posted November 13, 2012 Share Posted November 13, 2012 Don't know CI much, but ordinarily you would assign it to the view from within the controller. An nope that's not the correct syntax; print_r is a function. Check the manual for some examples. Quote Link to comment https://forums.phpfreaks.com/topic/270651-codeigniter-session-display/#findComment-1392151 Share on other sites More sharing options...
newmarket Posted November 13, 2012 Share Posted November 13, 2012 yep try print_r ( $this->session->all_userdata() ); Quote Link to comment https://forums.phpfreaks.com/topic/270651-codeigniter-session-display/#findComment-1392154 Share on other sites More sharing options...
Mahngiel Posted November 15, 2012 Share Posted November 15, 2012 Hi there. I am trying to display a session variable on the page. http://codeigniter.com/user_guide/libraries/sessions.html Set: $this->session->set_userdata('username', 'Mr. Balls'); Get: $this->session->userdata('username') However i am not sure if the code should be placed in the view or in the model? You put it wherever you want to use it. Quote Link to comment https://forums.phpfreaks.com/topic/270651-codeigniter-session-display/#findComment-1392499 Share on other sites More sharing options...
paulinetaylor85 Posted December 11, 2012 Share Posted December 11, 2012 Try this.. print_r($this->session->all_userdata()); --- $data['user'] = $this->User_model->getUserInformation($userid); --- $this->load->view('users', $data); Quote Link to comment https://forums.phpfreaks.com/topic/270651-codeigniter-session-display/#findComment-1398724 Share on other sites More sharing options...
raknjak Posted December 21, 2012 Share Posted December 21, 2012 just put it in the view Quote Link to comment https://forums.phpfreaks.com/topic/270651-codeigniter-session-display/#findComment-1400766 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.