Flashdata problem - 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: Flashdata problem (/showthread.php?tid=29398) Pages:
1
2
|
Flashdata problem - El Forum - 04-08-2010 [eluser]Ngulo[/eluser] hi i'm trying to set a simple flashdata controller: Code: $this->session->set_flashdata('error','this is an error'); view: Code: <?php echo $this->session->flashdata('error');?> but it doesn't works .... realy don't know what to do....i would like to set flashdata and not userdata ....please help me peoplesssss Flashdata problem - El Forum - 04-09-2010 [eluser]adamp1[/eluser] Have you checked in the cookie/database table to see if the value is getting saved there? If so what state is it in when you have loaded the view (i.e. is its state set to old/new). Reason I ask is a flashdata value can only be retrieved if its state is old. You cannot read flashdata which is new. Flashdata problem - El Forum - 04-09-2010 [eluser]Ngulo[/eluser] oh god .....i think i'm mistaking.... i didn't know that flashdata uses a DB table to store them self i always thought that they were contained into the $_SESSION array.... does it? my knowledge was that: userdata= $_SESSION(long time session set setting) flashdata= $_SESSION(short time session data setting) right? sorry for my bad english so i always need a table DB for storing my flashdata? Flashdata problem - El Forum - 04-09-2010 [eluser]erik.brannstrom[/eluser] No, storing sessions in a database is not the default behavior so - while recommended for sensitive data - it is not at all obligatory. The thing about flashdata is that it is only saved for ONE request. So if you set the data in a controller and then redirects to another controller method, only this second method will have access to the data. Thus, if you redirect again, the data will be lost (unless you specify it to be kept). Also, as adamp1 said, it cannot be directly accessed from the first method either, since there has to be one request between the setting and getting of the data. Does that help you at all? Flashdata problem - El Forum - 04-09-2010 [eluser]Ngulo[/eluser] Ok thanks for clarification So the redirect, removes the flashdata, I understand ...?? If I use a flashdata after a login page instead of doing a Code: $this->session->set_flashdata('error','this is an error'); I should make Code: $data['error1']=$this->session->set_flashdata('error','this is an error'); for reading the flashdata? right? Flashdata problem - El Forum - 04-09-2010 [eluser]erik.brannstrom[/eluser] No, the first one is right, however if there is a problem this probably depends on how your home controller looks like. Does the index method contain another redirect? Perhaps you could paste the code of that method. Flashdata problem - El Forum - 04-09-2010 [eluser]Ngulo[/eluser] hi man,thanks for supporting me the code are these into the controllers Controller home.php: Code: <?php Controller login.php : Code: <?php this to say that my home.php contain another redirect...so is this the problem?how to resolve that? really thanks p.s: do you think is the code right any suggestion also on that? thanks again Flashdata problem - El Forum - 04-10-2010 [eluser]erik.brannstrom[/eluser] I can't really wrap my head around your code.. Are you using re-routing of some sort or do you have an Admin controller that you haven't posted? I see that you set the flashdata when a user fails to login, but I don't understand where he is redirected, since if the user is redirected to the Home controller he will immediately be redirected once again to admin/admin. Also, it might be of interest to see how you display the data in your view. In regard to your code in general I would say that you are sort of misusing the form validation, however if this works just as you want it to then feel free to continue. Or rather, if this is how you want it to work, there isn't a need to even use the validation library. Flashdata problem - El Forum - 04-10-2010 [eluser]Ngulo[/eluser] Basically i have this configuration in my system directory view and controller folders Code: -System the views are home_view.php Code: <div id="form"> admin_view.php Code: <?php if($this->session->userdata('messaggio_upload')){echo $this->session->userdata('messaggio_upload');} ?> the fact is that I only let users with root username and password then you're right, the library validation form may not serve home.php serves on the redirect if the session exists ('administrator') to skip the form and enter directly into admin.php do not know if I said, excuse my English thank you Flashdata problem - El Forum - 04-10-2010 [eluser]Ngulo[/eluser] i have forgotten the admin.php controller Code: <?php |