CodeIgniter Forums
[SOLVED] Flashdata is not working - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: [SOLVED] Flashdata is not working (/thread-12039.html)

[SOLVED] Flashdata is not working - El Forum - 10-03-2008

Hi everyone. Time for another stupid question. I can't seem to get my flashdata working, but I have no problem with my userdata. Here's a test controller:

* Location: ./system/application/controllers/test.php
class Test extends Controller {
    function __construct()

    function index($params="") {

        // Set the flashdata
        $this->session->flashdata('flashdata', 'Some text');

        // Set some userdata
        $this->session->set_userdata('userdata', 'Some text');


    function next_page()
        echo "FLASHDATA: " . $this->session->flashdata('flashdata'). '<br />';

        echo "USERDATA: " . $this->session->userdata('userdata'). '<br />';

Here's the output I get:

USERDATA: Some text

I'm wondering if it's Swiftfox 3 that's to blame here. I've been having trouble with CSS files. It seems to load the cached file when it chooses, even when the cache is supposedly empty, and disabled. I've also had problems with the "FAST REPLY" functionality on this site. When I click submit, I get redirected to the standard page for replying, and my post is not submitted. Refreshing the original page and then using "FAST REPLY" seems to work as expected.

So either Swiftfox is borked, or I am making a silly mistake. Any help would be appreciated. I can confirm that the controller above doesn't seem to work on Konqueror (Ubuntu's natvie file/web browser) either. It also doesn't work in Opera, or Epiphany.

Should I start hacking the session file to see if I can find where the problem might be happening? Obviously, I would replace it with the original when I'm done. I'm just so confused here. It works for everyone else...

[SOLVED] Flashdata is not working - El Forum - 10-03-2008

Eeek! Problem solved!

I should be calling "set_flashdata()", instead of "flashdata()". My mistake, I misread the guide...

On that note, I am interested to know why $this->session->flashdata cannot be used to set variables. The function returns the value of the data in the array, and I believe it could also set that data if called with a second parameter, containing the value. Then again, perhaps my preferred method is wrong, or not preferred among other people. Maybe having one function performing both read and write actions makes things more complex?