Welcome Guest, Not a member yet? Register   Sign In
Session issue
#1

(This post was last modified: 12-14-2017, 08:58 AM by yinkoh.)

Hello,

I'm getting confused with a session issue...

I'm using a parent controller (MY_Controller) for all others controllers. Each of them is correctly initiated with parent::__construct() and everything is going well.

Right now, I'm doing the backoffice part of my site and so, I need to store a flag for identified users.

PHP Code:
class MY_Controller extends CI_Controller
{
 public function 
__construct()
 {
 
 parent::__construct();
 
 $this->load->library->('session');
 
 }

PHP Code:
class Backoffice extends MY_Controller
{
 public function 
__construct()
 {
 
 parent::__construct();
 
 }

 public function 
index()
 {
 
 if ( ! $this->session->has_userdata('is_logged') )
 
   $this->load->view('login');
 
 else
    $this
->load->view('admin');
 
 }

 public function 
login()
 {
 
 if $this->input->post('user') == 'user' && $this->input->post('passwd') == 'passwd' )
 
  $this->session->set_userdata('is_logged' => 1);
 
 }


My problem is that session always gets empty unless I do not use the CI Session library and therefore uses $_SESSION from native php.

I just dont get what part is wrong in my code.


Ps: I've tried using both files or database driver in application/config/config.php but without any changes.
Reply


Messages In This Thread
Session issue - by yinkoh - 12-14-2017, 08:55 AM
RE: Session issue - by dave friend - 12-14-2017, 03:44 PM
RE: Session issue - by yinkoh - 12-15-2017, 12:34 AM
RE: Session issue - by InsiteFX - 12-15-2017, 04:20 AM
RE: Session issue - by dave friend - 12-15-2017, 06:53 AM
RE: Session issue - by yinkoh - 12-15-2017, 07:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB