Welcome Guest, Not a member yet? Register   Sign In
Weird flashdata problem
#1

[eluser]frist44[/eluser]
I have a helper function that redirects a page and sets a message, which comes from a language file. That message is displayed in a div at the top of my main container. So if the flash data key "error" is not null, it'll display.

My issue is:

I have a controller that has a postback with validation. I check a lot of things and if they're bad I run the redirect_with_error function as shown below:

Code:
function redirect_with_error($url, $language_key, $txt = FALSE)
    {  
        $CI = &get;_instance();
        
        $msg = language($language_key) . ' ';
        $msg .= $txt ? $txt : '';
        
        $CI->session->set_flashdata('error', $msg);
        redirect($url);
    }

Problem is that my message is coming up at the top of my page, but i'm getting the redirect. So somehow the flash data is being set, but it shouldn't be. If I comment out the line of the code with that function call, it goes away. But I put an "echo 'test'; exit; " before that function, and it never runs, which would make sense because the page isn't actually redirecting. Here's the call:

Code:
if ($request = $this->requests_model->get_request_details_for_fulfillment($requestid)) {
                    $this->_fulfillment = TRUE;
                    $data['request'] = $request;                    
                    $data['supplierpay'] = get_supplier_pay_from_purchase_price($request['price']);  
                } else {
                    redirect_with_error(base_url(), 'flash_error_supply_purchase');
                }

I have proved that $request if filled and has data, so it should never go to "else" and it doesn't, but for some reason it's displaying the message. i have checked and that message isn't used anywhere else on the site. I should also mention that I put an echo statement before the set_flashdata call in the library and it never went off. So the flash data is actually showing up without a call to the function in the session library to set it. I have no idea how this could happen!!!!

It's driving me crazy...any ideas how flash data could be set like this without actually setting it intentionally.




Theme © iAndrew 2016 - Forum software by © MyBB