Hai,
I am using MySQL table to store session values. i am getting sid as 'deleted' for some sessions in live server . but i am not able to simulate it in development server .
what scenario it will occur.
sample data.
+---------+-------+-------------+
| sid | value | expire_time |
+---------+-------+-------------+
| deleted | | 1275216246 |
+---------+-------+-------------+

When u r inserting record in this table? meance post php code sample.
what is structure of this table?

The details are given
The table structure

CREATE TABLE `tbl_session` (
`sid` char(100) NOT NULL DEFAULT '',
`value` text,
`expire_time` int(14) unsigned DEFAULT NULL,
PRIMARY KEY (`sid`)
) ENGINE=InnoDB;

PHP Code:

<?php
$SESS_LIFE = get_cfg_var("session.gc_maxlifetime");
$SESSval = get_cfg_var("session.gc_probability");

function open_ses()	{
	return true;
}

function close_ses(){
	return (true);
}
function read_ses($session_id)	{
	global $SESS_LIFE,$MASTERCONN;
	
	$value = "";
	 $sql_read="select value from tbl_session where sid = '$session_id' and expire_time >= UNIX_TIMESTAMP() - $SESS_LIFE ";
	$result=mysql_query($sql_read,$MASTERCONN);
	$number_of_rows = mysql_num_rows($result);
	if (0 < $number_of_rows) {
	   	list($value)=mysql_fetch_array($result);
	}
	elseif(0 == $number_of_rows){
                $sql_ins = "insert into tbl_session (sid,expire_time) values ('".session_id()."',UNIX_TIMESTAMP())";
                $res_ins = mysql_query($sql_ins,$MASTERCONN);
	}
	return stripslashes($value);
}
function write_ses($session_id, $value){
	
	global $MASTERCONN;	
	$value = addslashes($value);
	$sql_upd = "update tbl_session set value = '$value',expire_time=UNIX_TIMESTAMP() where sid='$session_id'";
	$res_upd =  @mysql_query($sql_upd,$MASTERCONN);
	
	if (!$res_upd){
		return false;
	}
   	return true;
}

function destroy_ses($session_id){
	global $MASTERCONN;
	setcookie("PHPSESSID","",time()-100,"/");
	$sql_del_des = "delete from tbl_session where sid = '$session_id'";
	$res_del_des = mysql_query($sql_del_des,$MASTERCONN);
	return true;
}

function gc_ses($max_time){
	global $MASTERCONN;
	$sql_del_gc = "delete from tbl_session where expire_time < UNIX_TIMESTAMP() - $max_time";
	$res_del_gc = mysql_query($sql_del_gc,$MASTERCONN);
	if (!$res_del_gc)
		return false;
	return true;	
}
session_set_save_handler ("open_ses", "close_ses", "read_ses", "write_ses", "destroy_ses", "gc_ses");
ob_start();
session_start();
?>

Log out funciton

function doLogout()
{	
	if (!function_exists('open_ses'))
		include("session_handle.php");
	session_regenerate_id(TRUE);
	session_destroy();
	@header("Location:login.php");
	exit;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.