First things first so you guys got some background, i'm a junior dev who uses mainly Laravel, however for this project only, the team are mostly adept at codeigniter 3 so i have to adapt, and is currently kinda bewildered.
So the problem is this: The sessions are saved into the database, i set a userdata session but it can't be accessed without first doing an ajax post in the first page.
Most of the variables and function will be trimmed and/or changed since i signed an NDA.
In the very first controller we read the raw post inputs from android webview and set the userdata like this:
//this data_one is from android webview
$data_one = file_get_contents('php://input');
if($data_one){
$obj = (array) json_decode($data_one);
$this->phone = '';
if(isset($obj['phone'])){
$this->phone = $obj['phone'];
}
}
if($this->phone != ''){
$session_data = array('page_data' => array("pg" => array("phone" => $this->phone)));
$this->session->set_userdata($session_data);
}
//there's some data thrown into the data array before loading view, but NDA, so trimmed.
$this->load->view('first_page', $data);
In the view there is a select that will post an ajax request and then redirect to the next page. However, i'm currently doing another page that can be accessed before the ajax request from the first page.
The "Another Page" relies on the phone number userdata from first page to get other data. However, if the user haven't selected any options from the first page, the userdata returns empty and it defaulted to the initialization of the $phone variable in "Another Page" controller.
Do you guys have any idea why that is? i'm stuck on this for days and my "caveman solution" is to just move the link of "Another Page" to "Next Page", however that's kinda bad UX since user IS SUPPOSED TO be able to access "Another Page" from anywhere.