![]() |
How to pass a value from a Model to a controller that did not call that Model - 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: How to pass a value from a Model to a controller that did not call that Model (/showthread.php?tid=56058) |
How to pass a value from a Model to a controller that did not call that Model - El Forum - 11-23-2012 [eluser]alvaroeesti[/eluser] Hello, After checking at the Model that username and password are correct I want to go to the Administration panel. First, I dont know if I am "going the right way" because I am using a Code: header("Location: http://localhost/realestate/etc/"); I mean, it takes me alright, but I dont know if that is the way to do it, because the second issue is that at the Admin Panel I need to have that thing of Welcome Username and the logout link, and it is that Username that I am sending from the Model. I imagined I would do the session_start () at the Administration panel and then I would do $_SESSION('username') = $username; any idea what the way to send the $username from the Model so that I can pick it up at the Admin panel? thank you How to pass a value from a Model to a controller that did not call that Model - El Forum - 11-23-2012 [eluser]Otemu[/eluser] You could use Code: redirect('realestate/etc','refresh') In the model once you have checked the user exists in the database, you could do something like this Code: //your model Hope that helps How to pass a value from a Model to a controller that did not call that Model - El Forum - 11-23-2012 [eluser]alvaroeesti[/eluser] yeah, that should help!, thank you! How to pass a value from a Model to a controller that did not call that Model - El Forum - 11-23-2012 [eluser]alvaroeesti[/eluser] Hello I tried the snippet as you indicated and it was giving me errors, basically the value was not passed on in the session, that is, the isset would fail. So, I went and tried this: Code: $newdata = array( I understand your code as it is straightforward, but for some reason, codeigniter didnt like it, so I went to read the session userguide instructions and well, it works. I am positively sure your code is correct but like I said, maybe some scheme of my code doesn't take it as such. But your point did help me because I saw the logic, then I just put a syntax that worked for me. thank you How to pass a value from a Model to a controller that did not call that Model - El Forum - 11-23-2012 [eluser]Otemu[/eluser] Sorry forgot to tell you to add session_start(); I was using Native sessions and not codeigniter sessions But anyway least you solved it ![]() How to pass a value from a Model to a controller that did not call that Model - El Forum - 11-23-2012 [eluser]alvaroeesti[/eluser] yes, exactly in an afterthought I had that was the reason. It is said that codeigniter sessions are not reliable... I ll see how that goes, and if it keeps fine then ok, otherwise, I ll switch to native php sessions. thanks again |