Welcome Guest, Not a member yet? Register   Sign In
Flashdata being set but can't be echoed
#1

[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/.
#2

[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... ?
#3

[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.
#4

[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.
#5

[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
#6

[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]
#7

[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
#8

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




Theme © iAndrew 2016 - Forum software by © MyBB