Jump to content


Photo

Codeigniter Session Display


  • Please log in to reply
5 replies to this topic

#1 Pain

Pain

    Advanced Member

  • Members
  • PipPipPip
  • 177 posts
  • LocationLondon, UK

Posted 13 November 2012 - 05:38 PM

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 by Pain, 13 November 2012 - 05:47 PM.


#2 Adam

Adam

    Advanced Member

  • Gurus
  • 5,693 posts
  • LocationSheffield / UK

Posted 13 November 2012 - 05:57 PM

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. 

#3 newmarket

newmarket

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 13 November 2012 - 06:22 PM

yep try

print_r ( $this->session->all_userdata() );

#4 Mahngiel

Mahngiel

    Advanced Member

  • Members
  • PipPipPip
  • 1,076 posts

Posted 14 November 2012 - 07:21 PM

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.
?????????????????? This is a signature ????????????????????????

What do you  mean "so please write the code for me . . . "? We aren't here in gleeful anticipation just waiting to write code for you, you know.

CodeIgniter Libraries: Image Lib | Paginator Lib | AJAX Upload

#5 paulinetaylor85

paulinetaylor85

    Member

  • Members
  • PipPip
  • 11 posts

Posted 11 December 2012 - 07:19 AM

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

#6 raknjak

raknjak

    Advanced Member

  • Members
  • PipPipPip
  • 53 posts

Posted 21 December 2012 - 09:45 AM

just put it in the view
needs more cowbell




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com