Welcome Guest, Not a member yet? Register   Sign In
uri_string() or flashdata problems..
#1

[eluser]neph[/eluser]
i'm using a value of $this->session->set_flashdata('lastPage', $this->uri->uri_string()) and setting the redirect url as redirect($this->session->flashdata('lastPage')...i've just started to notice that in various places it redirects to favicon.ico, or a png file, or a .js file, below is an example of what's shown with the debug output and ci_sessions via mysql. for some reason it does 3 updates for the the ci_sessions table, the last of which has the correct ur_string value. i've validated my xhtml on each page involved...not quite sure what could be causing an intermittent issue like this...any help would be appreciated it. * the example below shows session->userdata instead of flashdata, both have the same effect*

Code:
DATABASE:  sfs   QUERIES: 6  
0.0009      SELECT *
FROM (`ci_sessions`)
WHERE `session_id` = 'cfca2b0a76d7d48dd6b632e02684be63'
AND `user_agent` = 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4'
0.0174      UPDATE `ci_sessions` SET `last_activity` = '1245819689', `user_data` =
'a:8:{s:8:\"lastPage\";s:49:\"/js/tiny_mce/plugins/filemanager/editor_plugin.js\";s:7:\"message\";a:1:
{s:7:\"success\";s:22:\"7 deleted successfully\";}s:8:\"username\";s:5:\"chris\";s:5:\"email\";s:19:\"[email protected]\";s:2:\"id\";s:1:\"1\";s:5:\"admin\";s:4:\"TRUE\";s:17:\"flash:new:message\";a:1:{s:7:\"success\";s:34:\"Blog Category created successfully\";}s:17:\"flash:old:message\";a:1:{s:7:\"success\";s:34:\"Blog Category created successfully\";}}' WHERE `session_id` = 'cfca2b0a76d7d48dd6b632e02684be63'
0.0011      UPDATE `ci_sessions` SET `last_activity` = '1245819689', `user_data` = 'a:7:{s:8:\"lastPagee\";s:49:\"/js/tiny_mce/plugins/filemanager/editor_plugin.js\";s:7:\"message\";a:1:
{s:7:\"success\";s:22:\"7 deleted successfully\";}s:8:\"username\";s:5:\"chris\";s:5:\"email\";s:19:\"[email protected]\";s:2:\"id\";s:1:\"1\";s:5:\"admin\";s:4:\"TRUE\";s:17:\"flash:old:message\";a:1:{s:7:\"success\";s:34:\"Blog Category created successfully\";}}' WHERE `session_id` = 'cfca2b0a76d7d48dd6b632e02684be63'
0.0007      SELECT blog_categories.name as bcat, blog_categories.*
FROM (blog_categories)
0.0011      UPDATE ci_sessions SET last_activity = '1245819689', user_data = 'a:7:{s:8:\"lastPage\";s:18:\"/admin/blogs/index\";s:7:\"message\";a:1:{s:7:\"success\";s:22:\"7 deleted
successfully\";}s:8:\"username\";s:5:\"chris\";s:5:\"email\";s:19:\"me@me\";s:2:\"id\";s:1:\"1\";s:5:\"admin\";s:4:\"TRUE\";s:17:\"flash:old:message\";a:1:{s:7:\"success\";s:34:\"Blog Category created successfully\";}}' WHERE `session_id` = 'cfca2b0a76d7d48dd6b632e02684be63'
0.0002      SELECT *
FROM (plugins)
WHERE `pluginActive` = '1'
ORDER BY pluginName ASC

<!-- the 3 lastPage references from that page load -->
{s:8:\"lastPage\";s:49:\"/js/tiny_mce/plugins/filemanager/editor_plugin.js\"
s:8:\"lastPagee\";s:49:\"/js/tiny_mce/plugins/filemanager/editor_plugin.js\"
{s:8:\"lastPage\";s:18:\"/admin/blogs/index\";
#2

[eluser]haydenp[/eluser]
neph

I was getting the same last night when I was testing some code. 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()

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???

Were you able to get to the bottom of this?
#3

[eluser]haydenp[/eluser]
FYI

Just seen this ... forum post

I had the profiler running when I was getting the error, switched it off and the flashdata was working 100% again.

If I switched the profiler back on I would get things like "site_assets/images/site/icon_footer.gif.html" added to the end of the return url?
#4

[eluser]haydenp[/eluser]
Mmmmm ... after a lot of trial and error I have now "fixed" this.

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.

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.

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

NOTE: This is WITH the profiler running on the page, so it is not "profiler" related as far as I can tell.

Conclusion

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




Theme © iAndrew 2016 - Forum software by © MyBB