Using flashdata after redirect? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Using flashdata after redirect? (/showthread.php?tid=63589) Pages:
1
2
|
Using flashdata after redirect? - JayAdra - 11-17-2015 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! RE: Using flashdata after redirect? - arma7x - 11-17-2015 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() RE: Using flashdata after redirect? - JayAdra - 11-17-2015 Yes I thought that could have been the issue, but I'm not destroying any sessions, so the flashdata should be intact. RE: Using flashdata after redirect? - wolfgang1983 - 11-17-2015 (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 }?> RE: Using flashdata after redirect? - JayAdra - 11-17-2015 I forgot to mention that I also tried that - it didn't help. Thanks for the suggestion though. RE: Using flashdata after redirect? - Sentro - 11-17-2015 Try adding in the login constructor and see if that works. PHP Code: $this->session->keep_flashdata('message'); Also remove 'refresh' from the redirect. RE: Using flashdata after redirect? - Bhavesh - 11-17-2015 Hi Please check "$this->load->library('session');" writing or not in controller (log out) action RE: Using flashdata after redirect? - JayAdra - 11-17-2015 (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. RE: Using flashdata after redirect? - Martin7483 - 11-17-2015 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? RE: Using flashdata after redirect? - ivantcholakov - 11-17-2015 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. |