MY_controller problem |
[eluser]Near[/eluser]
Hi! I'm creating a program which allows user to register and log in to a specific page. This is my problem: 1) validates user if registered or not 2) determine if the user is currently logged in i managed to finish the first issue. but the second issue. I created a my_controller which extends the ci_controller. then i declare a global variable called $is_login.. I can set its value to true on one page. But when i load another page. The value of the variable $is_login was set to false.. Am i doing it wrong?do i have to store the variable to session instead of using my_controller? Thanks!
[eluser]Near[/eluser]
here is my_controller Code: class base_c extends ci_controller{ welcome controller Code: class welcome extends base_c{ Code: function is_login(){
[eluser]marcogmonteiro[/eluser]
Code: class base_c extends ci_controller{ perhaps something like this?
[eluser]CroNiX[/eluser]
If you are going to extend a MY_Controller you will need an autoloader for it to find the class. It also doesn't look like you are extending things properly and/or perhaps don't have the extended base classes in the appropriate directory (/application/core) http://philsturgeon.co.uk/blog/2010/02/C...ing-it-DRY
[eluser]Near[/eluser]
Yes im able to set the $this->is_login to true if already logged in and false if not. The only problem that i encountered is that, for example im on the home page. The value of $is_login is true but when i click for example activities the value of $is_login is now FALSE..
[eluser]weboap[/eluser]
can you start by capping the Code: class Base_c extends CI_Controller{ then Code: //then echo the value of and post back the values in the 2 pages
[eluser]Near[/eluser]
Hi! Sorry for late reply. Everything is working fine. The capitalizations,declarations of variable. My_controller is located at applications/core... The only problem that i encounter is that when i request aq new page using redirect or other methods the controller variables are being set to FALSE. Do i have to store a session variable telling the user is logged in nd unset it after he logged out?
[eluser]weboap[/eluser]
using session is the most common. http://ellislab.com/codeigniter/user-gui...sions.html Code: $newdata = array( then Code: $logged_in = $this->session->userdata('logged_in'); |
Welcome Guest, Not a member yet? Register Sign In |