I have one issue with the codeignitor sessions. I create one controller called "Welcome.php" in that I have three functions. one is index, second one is home and last one is getAjaxTestData.
When I load welcome controller in browser (http://localhost:9019/welcome) it will call index function by default and sets some session and it loads the welcome view. In the view file I am sending the ajax request to getAjaxTestData function and in that function I set sleep 50 seconds.
Once ajax request is called, it waits for the 50 seconds. In the mean time if I open another link by calling Home function link "https://localhost:9019/welcome/home" it is not loading till the previous ajax request is completed.
This is happening only when I set sessions. If I do not set sessions, then even if I set sleep in getAjaxTestData function, then https://localhost:9019/welcome/home will open immediately.
below is my controller- can you please check ..why the other pages are waiting to load till the previous page ajax request is completed when use sessions? is there any thing wrong?
Code in my Welcome.php controller
public function index()
{
$newdata = array(
'user_id' => "123",
'username' => "siddu",
);
$this->session->set_userdata($newdata);
session_write_close();
$this->load->view('welcome_message');
}
public function getAjaxTestData()
{
//echo "<pre>";print_r($this->session->userdata);echo "</pre>";die();
sleep(15);
$data=array();
$data['success']=0;
$data['start_time']=date("Y-m-d h:m:s");
$data['end_time']=date("Y-m-d h:m:s");
$data['success']=1;
echo json_encode($data);
die();
}
function Home()
{
$this->load->view('home');
}