檔案:
common/Common.config.php
include/session.inc.php
session_test.php
get_session_test.php
get_session_test2.php
* 作者戀愛* 資料庫配置
*/
/*
* 資料庫設定
*/
define( "DBTYPE", "mysql" );
"default" => array
(
"user" => "root",
"密碼" => "",
公款,
"會話" => 陣列
(
"使用者" => "會話",
"已" => "會話",
"dbname" => "sessions"
)
)
);
?>
session.inc.php
);
?>
session.inc.php
if ( !isset($include_path)) $include_path = '';
if (!is_array($database))
{
$DBsess_link = mysql_connect($DBsess["host"], $DBsess["user"], $DBsess["password" ])
em>無法連線到Mysql 伺服器。
函數sess_close()
{
回傳true;
}
function sess_read($ id)
{
全域$ dbsess,$ dessionans_m y mysql_gol_db($ = time();
, $DBsess_link);
if (list($數據) = mysql_fetch_row($result))
{
$data)
{ global $DBsess , $DBsess_link, $SESS_LIFE;
mysql_select_db ($DBsess["dbname"]);
$expiry_time = time() + $SESS_LIFE;
if ( !get_magic_quotes_gpc() )
}
$now = time();
$result = mysql_query("INSERT into `sessions` (`id`, `expiry_time`, `data`)", $DBsess_link); $result = mysql_query("更新`sessions` SET `data`='$data', `expiry_time`=$expiry_time
iry_time ` > $now", $DBsess_link);
}
回傳$結果;
}
function sess_destroy($id)
{
global $DBsess , $DBsess_link;
mysql_select_db($DBsess["dbname"]);
$query = mysql_query("從 `session` WHERE `id`='$id' 中刪除");
return $query;
}
function sess_gc($maxlifetime)
{
全域$DBsess , $DBsess_link;
$query = mysql_query("從 `sessions` 刪除,其中 `expiry_time` return mysql_affected_rows($DBsess_link);
}
session_module_name();
session_set_save_handler("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy","
include ("include/session.inc.php");
session_start();
$_SESSION[ "abc" ] = "A:我會回來的!";
$_SESSION["meto"] = "B:我也是";
echo "
?>
get_session_test.php
//測試使用session
include("common/Common.config.php");
include("includes.). session_start();/*
* www.knowsky.com
*/
$_SESSION["c"] = "
C:我會關注U。^0^! ";
print($_SESSION[" abc"]);
print("
");
echo "
".
"
?>
get_session_test2.php
//get_session_test2.php
//使用session測試檢測
include/session.inc.php");
session_start();
?>