I might have a wrong approach on this one BUT, is it possible to set a global variable in one controller function and access it through another one?
Here's what i mean:
PHP Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Groups extends CI_Controller {
private $page_id = ''; //
public function view($slug = false){
$this->load->model('some_random_model'); //Loading model
$info = $this->some_random_model->get_info($slug); //Getting more info
$this->page_id = $info['page_id']; //Setting a value in page_id variable
}
public function anotherFunction(){
$page_id = $this->page_id;
//Some code here
$this->load->view('group/anotherFunction');
}
}
Is this possible, or what's the best practice on that?
To give you a hint on what i'm trying to achieve.
Using an ajax request with get parameters from
"view" function, i'm calling
"anotherFunction()" and trying to get some info. What i want is to reassure that the "
page_id" is valid and the user is registered in that page.
In other words i want to handle those data in controller and not passing them with get parameters in the client side.
I hope i made my self clear.
If you have any questions or suggestions feel free to ask!
Thanks in advance!!
//Life motto
if (sad() == true) {
sad().stop();
develop();
}