Using session to display images

#1
[eluser]BigJoe[/eluser]
When a user logs in and CI loads it from the database. I'm trying to get CI to display the image.


Code:
$data = array(
  'user_rank'   => 'pro-guest.png';
);
$this->session->set_userdata($data);

Then I try and display this on the page.

Code:
echo '<img src="images/ranks/'.$this-&gt;session-&gt;userdata('user_rank').' ">';

So far nothing I tried seems to work. Any one have any ideas.

Joe




#2
[eluser]PhilTem[/eluser]
To avoid wrong URIs, try using

Code:
echo '<img src="' . base_url('images/ranks/' . $this-&gt;session-&gt;userdata('user_rank')) . '" />';

or even better with the img-helper

Code:
echo img('images/ranks/' . $this->session->userdata('user_rank'));

If you still don't see the image, make sure it is where it's supposed to be Wink

#3
[eluser]BigJoe[/eluser]
Thank you. That seems to work. It looks like I didn't type it in right. I had some in the ' and " missing and I fixed them

Thanks Again
Joe


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.