Welcome Guest, Not a member yet? Register   Sign In
Flashdata - adhoc image name being appended after setting its value.
#1

[eluser]haydenp[/eluser]
I needed to keep track of the current url so as to offer the user a "Return to previous page" link on the next page.

I was setting the flashdata in the usual way and setting its value to ... current_url()

Code:
$this->session->set_flashdata('return_url', current_url());

On the next page, my "Return to previous page" link was there but had a lot of "extra" bits added on to the end of the url.

Example of what I was expecting flashdata to hold on the "next page":

http://10.0.0.6/website/index.php/my_con...yz/10.html

Example of what flashdata was holding on the "next page":

http://10.0.0.6/website/index.php/my_con...r.gif.html

I noticed that the "icon_footer.gif" it was adding to the return url in the flashdata related to an image within the markup of the page AND ... no matter where I put this image within the markup it would always append it to the return url set in the flashdata. If I removed the image tag from the markup it would not be added to the return url set in the flashdata, and the flashdata would hold the expected return url correctly.

The markup in question:

Code:
<div class="footer_icon"><a href="#"><img src="assets/images/site/icon_footer.gif" alt="" /></a></div>

So how did I resolve this?

It was as simple as replacing the relative image path with its absolute path ... and bingo, the return url I was setting in my flashdata was no longer appending "rubbish" to the end of the url and that is with the profiler running on the page (see note below)

Code:
<div class="footer_icon"><a href="#"><img src="http://www.mysite.com/assets/images/site/icon_footer.gif" alt="" /></a></div>

Conclusion

There must be a a bug somewhere in CI relating to relative/absolute paths and flashdata?

NOTE: For full/further details on this please see the forum thread here




Theme © iAndrew 2016 - Forum software by © MyBB