Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Flashdata is not working
#1

[eluser]TheFuzzy0ne[/eluser]
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:

Code:
<?php
/**
* Location: ./system/application/controllers/test.php
*/
class Test extends Controller {
    function __construct()
    {
        parent::Controller();
    }

    function index($params="") {
        $this->load->helper('url');
        $this->load->library('session');

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

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

        redirect('/test/next_page');
    }

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

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

Here's the output I get:

Quote:FLASHDATA:
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...
#2

[eluser]TheFuzzy0ne[/eluser]
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?




Theme © iAndrew 2016 - Forum software by © MyBB