-1

I have a problem calling the payment controller, I've tried using

 session_start ();
// Turn off all error reporting
error_reporting (0); 

but the data I call does not show up if using it

this is problem

this is problem

this is my controller

this is my controller

Micho
  • 3,929
  • 13
  • 37
  • 40

2 Answers2

0

You should use $this->load->library('session'); and not session_start()

put $this->load->library('session'); inside a constructor on your controller

something like this

public function __construct()
{
   parent::__construct();
   $this->load->library('session');
}

check this How to fix “Headers already sent” error in PHP

Rex Martinus
  • 155
  • 10
  • I've added the library session, but it's still the same error session_start() – Randy Sepriyanda Nov 10 '17 at 10:38
  • @RandySepriyanda maybe you already load $this->load->library('session'); over a new one, if thats the case you shouldn't load more than one $this->load->library('session');. You have to load it once on every controller of your project. – Rex Martinus Nov 13 '17 at 03:50
0

You can use the "session" library of the codeigniter.

public function __construct(){
  parent::__construct();
  $this->load->library("session"):
}
//set session value
public function name-of-function(){
    $newdata = array(
        'username'  => 'johndoe',
        'email'     => 'johndoe@some-site.com',
        'logged_in' => TRUE
     );
     $this->session->set_userdata($newdata);
}
//accessing session value
public function()
{
   $username = $this->session->userdata("username");
   echo $username;
}

in the above function we are initialising the session library then setting session values and then accessing those value from the session. Hope it will help you.

for more information: https://www.codeigniter.com/user_guide/libraries/sessions.html