Jump to content

Archived

This topic is now archived and is closed to further replies.

Pain

Codeigniter Session Display

Recommended Posts

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:)

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Try this.. print_r($this->session->all_userdata()); --- $data['user'] = $this->User_model->getUserInformation($userid); --- $this->load->view('users', $data);

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.