CodeIgniter Forums
Flashdata being set but can't be echoed - 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: Flashdata being set but can't be echoed (/showthread.php?tid=24406)



Flashdata being set but can't be echoed - El Forum - 11-09-2009

[eluser]ChazUK[/eluser]
I'm having a real problem here.

I've been trying to use the session->flashdata() functions because I can see a real use for them, but I can't seem to echo any of the data out on the next page.

Example
/anypage/
Code:
$this->ci->session->set_flashdata('referrer', uri_string());
redirect('/login/');

/login/
Code:
var_dump($this->session->flashdata('referrer'));

and it always comes out as bool(false).

I have looked in the DB and I can see that the stuff is being written as flashdata:new:referrer, but I can't access it on /login/.


Flashdata being set but can't be echoed - El Forum - 11-09-2009

[eluser]jedd[/eluser]
Do you have any other redirects in there? Flashdata only survives one page load, remember.

Why are you setting the data with $this->ci->session... and then retrieving it with $this->session... ?


Flashdata being set but can't be echoed - El Forum - 11-10-2009

[eluser]ChazUK[/eluser]
I'm using $this->ci-> inside of my own class, which doesn't extend any models or controllers.

There is only that 1 redirect.


Flashdata being set but can't be echoed - El Forum - 11-10-2009

[eluser]jedd[/eluser]
[quote author="ChazUK" date="1257870018"]
I'm using $this->ci-> inside of my own class, which doesn't extend any models or controllers.
[/quote]

Ahh .. that's interesting, isn't it.

Why not just $ci?

But I digress.

If you set some normal session data, in that place, can you retrieve it at the other end? It'd be good to know whether all session data is breaking, or just flash. Basic trouble-shooting and all that. It's not clear if you've already tried this.


Flashdata being set but can't be echoed - El Forum - 11-10-2009

[eluser]ChazUK[/eluser]
I have this in my htaccess file

Code:
RewriteEngine On
RewriteBase /

# this adds trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ $1/ [R=301,L]

# this gets rid of index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1



Flashdata being set but can't be echoed - El Forum - 11-10-2009

[eluser]jedd[/eluser]
[quote author="jedd" date="1257871903"]
If you set some normal session data, in that place, can you retrieve it at the other end?
[/quote]


Flashdata being set but can't be echoed - El Forum - 11-10-2009

[eluser]ChazUK[/eluser]
Yep, just tried using session->userdata and I can echo it right after I've set it, and I can see that it's been set in the db, but on the next page, it doesn't echo and the next session entry is empty in the DB


Flashdata being set but can't be echoed - El Forum - 11-10-2009

[eluser]ChazUK[/eluser]
It appears that because I was developing on localhost, I needed to have my cookie_domain set to empty.