Welcome Guest, Not a member yet? Register   Sign In
How to keep flash data in Codeigniter?
#1

[eluser]Sein Kraft[/eluser]
I've a controller with a method there it catch an argument and set it in a flash var.

The question is...if i send many arguments to this method, using multiple firefox tabs but the same user session, could them get mixed or rewrited?

I mean, if i open a tab and send the "x" argument and is saved in a flash var and in another tab i send the argument "y" and is "x" rewrited by "y" or is handled like two different things? (i'm using stored sessions)

Also i'm having troubles keeping flash data. It don't keep for next use if i change between sections. If i go to modify/general the flashdata is deleted (replaced by 0).

My code:
Code:
function modify(){
    $section = $this->uri->segment(3);

    switch ($section) {
        case 'identity':
                $this->session->keep_flashdata('item');
                $this->_modify_identity();
            break;
        case 'general':
                $this->session->keep_flashdata('item');
                $this->_modify_general();
            break;
        case 'print':
                echo $this->session->flashdata('item');
            break;
        default:
                if(is_numeric($section)){
                    $this->session->set_flashdata('item', $section);
                }
                redirect('profile/modify/identity');
            break;
    }
}
#2

[eluser]Sein Kraft[/eluser]
Lol nobody can answer this?
#3

[eluser]iloveci[/eluser]
Why are you using flashdata instead of sessiondata if you need to save the data?
#4

[eluser]Cristian Gilè[/eluser]
Quote:The question is…if i send many arguments to this method, using multiple firefox tabs but the same user session, could them get mixed or rewrited?

The sessions are overwritten!

Quote:Also i’m having troubles keeping flash data. It don’t keep for next use if i change between sections. If i go to modify/general the flashdata is deleted (replaced by 0).

Please, post the code of the _modify_general() method;


Cristian Gilè
#5

[eluser]Sein Kraft[/eluser]
_modify_general() method dont contain anything that could remove the flash data. Also i've tried removing that line and still dont work.
#6

[eluser]Cristian Gilè[/eluser]
According to the code and your explanation:

1. You set a flash session var called 'item' ($this->session->set_flashdata('item','some value'))
2. You redirect to modifiy() method
3. You switch the section (third uri segment), and if it is 'identity' or 'general' you keep the flash data for a next request

So, in the _modify_general() method, you call a new redirect. Right?


Cristian Gilè
#7

[eluser]Sein Kraft[/eluser]
_modify_general() is a simple form validation, is data is submited then it clears the flashdata and redirects the user.

The problem is that the flash data is cleared before, only in the menu switch. I mean if i remove that line and switch between "links" (method swithc) it is cleared or simply dont keep it.

Of flash data only is keeped on redirects? not in user clicks?
#8

[eluser]InsiteFX[/eluser]
Everytime you open a new tab it is a new window!

And for every new window the session stuff is assigned
a new session_id etc.

InsiteFX
#9

[eluser]Sein Kraft[/eluser]
[quote author="InsiteFX" date="1296548909"]Everytime you open a new tab it is a new window!

And for every new window the session stuff is assigned
a new session_id etc.

InsiteFX[/quote]

But...i'm using keep_flashdata('item')...this should keep the current data IF i don't open another window but it don't work.
#10

[eluser]skunkbad[/eluser]
[quote author="Sein Kraft" date="1296549073"][quote author="InsiteFX" date="1296548909"]Everytime you open a new tab it is a new window!

And for every new window the session stuff is assigned
a new session_id etc.

InsiteFX[/quote]

But...i'm using keep_flashdata('item')...this should keep the current data IF i don't open another window but it don't work.[/quote]

You should check your server access log for requests. All it takes is one request, even a 404 from an image file that didn't exist, and the flash data is gone.




Theme © iAndrew 2016 - Forum software by © MyBB