Using flashdata after redirect? |
I humbly request some assistance.
I am setting some flashdata just prior to using a "redirect" and the flashdata is not saving/showing up after the redirect. My code is as follows: PHP Code: $this->session->set_flashdata('message', 'test'); On the login page though ("login" controller function), the flashdata isn't showing up. Here are some things to note:
Thanks!
I'm also having the same problem, but in my situation is after logout progress which is in my code
$this->sessions->sess_destroy(); $this->session->set_flashdata('message','Successfully logout'); redirect('login'); Solve the problem by add sess_regenerate() after sess_destroy()
Keep calm.
Yes I thought that could have been the issue, but I'm not destroying any sessions, so the flashdata should be intact.
(11-17-2015, 01:08 AM)JayAdra Wrote: Yes I thought that could have been the issue, but I'm not destroying any sessions, so the flashdata should be intact. Try removing this 'refresh' in your redirect I think that is why flash data not showing. and then on login view <?php if ($this->session->flashdata('message')) {?> <?php echo $this->session->flashdata('message');?> <?php }?>
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
I forgot to mention that I also tried that - it didn't help. Thanks for the suggestion though.
Try adding in the login constructor and see if that works.
PHP Code: $this->session->keep_flashdata('message'); Also remove 'refresh' from the redirect.
"The Most Important Thing In Life Is Showing Up"
"I Just Had A Bad Day" "We'll Be Back" "Further Beyond"
Hi
Please check "$this->load->library('session');" writing or not in controller (log out) action (11-17-2015, 04:41 AM)Sentro Wrote: Try adding in the login constructor and see if that works. Yeah I did try this, as I mentioned in point 3 - I have tried it again now (and removed refresh from the redirect) and it's still not working. Appreciate the suggestion though.
Have you tried
PHP Code: var_dump($_SESSION); After setting it? PHP Code: $this->session->set_flashdata('message', 'test'); Is the message available in the $_SESSION array?
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. |
Welcome Guest, Not a member yet? Register Sign In |