复制代码 代码如下:
CREATE DATABASE 'session'; 创建表结构 CREATE TABLE 'session'( id CHAR(30) NOT NULL , 'user 'CHAR(30), data CHAR(3000) ,PARMIRY BY ('id') );
复制代码 代码如下:
<?php
$con =mysql_connection("127.0.0.1","user" , "pass");
mysql_select_db("session");
function open($save_path, $session_name)
{
return(true);
}
function close()
{
return(true);
}
function read($id)
{
if($result = mysql_query("SELECT * FROM session WHERE"))
{
if($row = mysql_felth_row($result ))
{ return $row["data"]; }
}
else
{
return "";
}
}
function write($id, $sess_data)
{
if($result = mysql_query("UPDATE session SET data='$sess_data' WHERE"))
{
return true;
}
else
{
return false;
}
}
function destroy($id)
{
if($result = mysql_query("DELETE * FROM session WHERE"))
{
return true;
}
else
{
return false;
}
}
/*********************************************
* WARNING - You will need to implement some *
* sort of garbage collection routine here. *
*********************************************/
function gc($maxlifetime)
{
return true;
}
session_set_save_handler("open", "close", "read", "write", "destroy", "gc");
session_start();
// proceed to use sessions normally
?>
新闻热点
疑难解答