Problem with session flashdata - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Problem with session flashdata (/showthread.php?tid=9598) |
Problem with session flashdata - El Forum - 07-01-2008 [eluser]kevinh21[/eluser] Hi everyone I'm programming an administrator-backend for my website. I use the erkanaauth library to make this easier. Now i have some problems with flashdata to show a message when the access is denied. admin controller: Code: function settings() admin/login.php (view): Code: <div class="content wide"> The Problem: If i call admin/settings, it should check if i'm logged in. If not, it should set a flashdata message (status) and show the admin/login.php view with my function showSite(). In this view, it should display the flashmessage i set. But he is not showing the message when i'm cliking on a link that refers to admin/settings. I need to click at least twice, then it will show me the flashmessage. What i'm doing wrong? Problem with session flashdata - El Forum - 07-01-2008 [eluser]kevinh21[/eluser] Hi again The problem must be here: Code: function settings() if i then do it again and from this point it will write "TESTYou must be logged...." I don't understand why Problem with session flashdata - El Forum - 07-01-2008 [eluser]Yash[/eluser] do something like this Code: $login = $this->session->userdata('logged_in'); Just check that and use this code. Problem with session flashdata - El Forum - 07-01-2008 [eluser]kevinh21[/eluser] Hi Yash Thanks for your answer but i think you misunderstood me. The if-code is working fine, i think i should make it a bit more understandable by reducing the code: function settings() { $this->session->set_flashdata('status', 'You must be logged in to view this page'); echo 'TEST'.$this->session->flashdata('status'); } This part is making the problem. Sometimes when i execute this function by browsing to localhost/admin/settings or clicking a link that refers to this, it will only write "TEST" and the session flashdata in 'status' seems not to be set. When i reload the page, it will write "TESTYou must be logged in to view this site". I don't understand why it sometimes doesn't have set this flashdata. Most of the times this is the case after i executed other functions. Problem with session flashdata - El Forum - 07-09-2008 [eluser]makedjakila[/eluser] Hi Kevinh21 ! You need to understand how Session works in PHP : You need to load another page to see the session data. It means that you have to set a redirection if you want to see your flashdata at the first time. Regards, Makedjakilabee |