Constructor session validation for different functions

后端 未结 2 1285
广开言路
广开言路 2020-11-30 13:40

I\'m doing a validation in my constructor which checks whether the user has started a session.

I\'m then throwing in some controllers for various things.

My

2条回答
  •  广开言路
    2020-11-30 13:53

    As stated earlier why don't you use separate different base controllers for specific purpose.

    I would suggest as this way for you

    let us take two part one let's say frontend controller which donot require session and another controller let's say backend controller which needs session Now,

    //application/core/Front_controller.php
    
    class Front_Controller extends MY_Controller
    {
     function __construct()
         {
                 parent::__construct();
    
       }
     }
    

    another class under core/backend_controller

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

    now you can extend the front_controller for those controller you do not need session and extend backend controller which requires session from application/controller

提交回复
热议问题