prevent cookie when running script from CLI in codeigniter prevent cookie when running script from CLI in codeigniter codeigniter codeigniter

prevent cookie when running script from CLI in codeigniter


The simplest way I think would be to extend the Session class like this :

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');class MY_Session extends CI_Session{    public function __construct()    {        $CI = get_instance();        if ($CI->input->is_cli_request())        {            return;        }        parent::__construct();    }}

Just place it in the application/libraries folder. And with a controller like this :

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');class Welcome extends CI_Controller{    public function no_cli_session()    {        $this->load->library('session');        $this->session->set_userdata('logged', 'yes');    }}

When you call the function from your browser the session is set and when you call it from cli it is not.