Welcome Guest, Not a member yet? Register   Sign In
Using flashdata after redirect?
#11

(11-17-2015, 12:21 PM)Martin7483 Wrote: Have you tried
PHP Code:
var_dump($_SESSION); 

After setting it?

PHP Code:
$this->session->set_flashdata('message''test');
var_dump($_SESSION);
exit;
redirect('login''refresh'); 

Is the message available in the $_SESSION array?

I checked this and yes, the message is available in the $_SESSION array:

Code:
array (size=3)
 '__ci_last_regenerate' => int 1447806257
 'message' => string 'Update successful.' (length=18)
 '__ci_vars' =>
   array (size=1)
     'message' => string 'new' (length=3)

This was the dump before the redirect.

(11-17-2015, 01:36 PM)ivantcholakov Wrote: Is there an AJAX request? Maybe it somehow captures and clears the flashdata before the redirection?

A side note:
When AJAX is called by jQuery
headers["X-Requested-With"] = "XMLHttpRequest";
is done automatically, but in other cases this header might be forgotten.

No, there is no AJAX request. It is a normal form submission (POST request).
Reply
#12

(11-17-2015, 05:33 AM)Bhavesh Wrote: Hi

Please check "$this->load->library('session');" writing or not in controller (log out) action

I am autoloading the session library, so yes it is being loaded. All my other flashdata for form validation etc. works fine, it's only when using a redirect() that it doesn't work.
Reply
#13

UPDATE: I found some random old code I had in my app which messed with the flashdata - I don't remember putting it there, and looking at it now, I have no idea what purpose it was serving...

Anyway, point is I got it working now! Thanks for the suggestions.

Now just to figure out how to get it working after destroying the session...
Reply
#14

(11-17-2015, 09:15 PM)JayAdra Wrote: UPDATE: I found some random old code I had in my app which messed with the flashdata - I don't remember putting it there, and looking at it now, I have no idea what purpose it was serving...

Anyway, point is I got it working now! Thanks for the suggestions.

Now just to figure out how to get it working after destroying the session...


Any chance I could borrow that "random old code" that helped with your problem losing flashdata after redirect()?

I'm having exactly the same issue as you're describing. There is an "exit;" in the CI's redirect function that is breaking flashdata. It works fine if, instead of redirect(), you use, for example, header('Location: '.base_url().'blah') with no following exit. But the exit is good practice. It **should** be there.
Reply
#15

(11-17-2015, 09:15 PM)JayAdra Wrote: UPDATE: I found some random old code I had in my app which messed with the flashdata - I don't remember putting it there, and looking at it now, I have no idea what purpose it was serving...

Anyway, point is I got it working now! Thanks for the suggestions.

Now just to figure out how to get it working after destroying the session...

JayAdra, Can you please help me out, i'm facing the same problem... Confused
Reply




Theme © iAndrew 2016 - Forum software by © MyBB