• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controllers using private variables

Hello am a codeigniter newbie and am in love with this frame work. I have hit a snag in controllers where by i want to use a private variable in two controllers like this

class data extends CI_Controller{
private $somedata;

public function index(){
$this->somedata="Got Data here";


public function showData(){
echo $this->somedata;


In the above code when i run the showData() controller it is always empty (My gues is that the class is instantiated in each page am i right? e.g /home/ and /home/showdata will result in two different classes)

My question is how would i set variables in one controller to accessed in another controller?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.