Click here to Skip to main content
15,899,475 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai ,

I set Session timeout 180 minutes in php.ini file,But session value destroy in every 10 minutes.

session will destroy when i call another page using ajax.

how can i solve it

What I have tried:

the ajax code is

JavaScript
function countdata()
var userid= "<?php echo $_SESSION['user_id']; ?>";
$.ajax({
type: "POST",
url: "./webservice/usercountnotifi.php",
data:{user_id:userid},
success: function(data){
document.getElementById('update1').innerHTML = data;
lastentry();
}



in php

PHP
<?php
	include_once '../Login/db_connect.php';
	include_once '../Login/Functions.php';
	sec_session_start();
	$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);
	
	if(!isset($_SESSION['user_id']) )
	{
		header("location:../login.php");
		exit();
	}

	$userid = $_REQUEST['user_id']; 
	
	date_default_timezone_set("Asia/Kolkata");
	$startdate = date('Y-m-d');
});
?>


when i call usercountnotifi.php page the page resirect to login page
Posted
Updated 13-Nov-17 9:25am
v2
Comments
Kornfeld Eliyahu Peter 30-Oct-17 16:13pm    
What sec_session_start exactly does?
Nataraj Pandiyan 31-Oct-17 5:46am    
I Just Call this Function

function sec_session_start() {

ob_start();
session_start();
}
Kornfeld Eliyahu Peter 31-Oct-17 5:59am    
You are saying that you are calling a function you do not know? Why?
Its name is suspicious (like it starts a new secured session)... Remove the line and test again...
Mohibur Rashid 1-Nov-17 3:48am    
read this link http://php.net/manual/en/function.ob-start.php to understand ob_start function. in this case you have no use. You are supposed to get error for missing compulsory parameter. If there is error or warning, session_start might not work.
Mohibur Rashid 31-Oct-17 0:25am    
i can see you have db_connect.php and then you are connecting with mysql again

and what is sec_session_start()?

1 solution

Try
session_set_cookie_params(9999999999, '/', 'domain.com');
session_cache_expire(9999999999);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900