Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to pass an array from one class controller to another in codeigniter

I have two Controller such as doc.php, user.php in controller folder and a registration.php in a view folder, which have a registration form. i want to pass the registration info from registration.php to doc.php controller via user.php. How can i do this? Need help.

like image 735
Sohel Avatar asked Mar 16 '26 19:03

Sohel


1 Answers

What is your codeigniter version ? 2.x or 3.x ?

Try to use session to save your array.

To initialize the Session class manually in your controller constructor, use this method:

$this->load->library();

Once loaded, the Sessions library object will be available using:

$this->session

You can set you session name, using this code :

$this->session->your_session_name;

Use this to add an item in your session :

$this->session->your_session_name('item_one');

To retrieve your session, use this code :

$this->session->your_session_name;

Check this for CodeIgniter 3.X

Check this for CodeIgniter 2.X

like image 171
Cakka Avatar answered Mar 18 '26 09:03

Cakka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!