CodeIgniter Forums
Using session to display images - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Using session to display images (/showthread.php?tid=56314)



Using session to display images - El Forum - 12-09-2012

[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






Using session to display images - El Forum - 12-10-2012

[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


Using session to display images - El Forum - 12-10-2012

[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