<CODE><SPAN style="COLOR: rgb(0,0,0)">
<SPAN style="COLOR: rgb(0,0,187)"><?php
define</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(221,0,0)">'MY_SESS_TIME'</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(0,0,187)">3600</SPAN><SPAN style="COLOR: rgb(0,119,0)">); </SPAN><SPAN style="COLOR: rgb(255,128,0)">//SESSION 生存时长
//类定义
</SPAN><SPAN style="COLOR: rgb(0,119,0)">class </SPAN><SPAN style="COLOR: rgb(0,0,187)">My_Sess
</SPAN><SPAN style="COLOR: rgb(0,119,0)">{
function </SPAN><SPAN style="COLOR: rgb(0,0,187)">init</SPAN><SPAN style="COLOR: rgb(0,119,0)">()
{
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$domain </SPAN><SPAN style="COLOR: rgb(0,119,0)">= </SPAN><SPAN style="COLOR: rgb(221,0,0)">'.infor96.com'</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
</SPAN><SPAN style="COLOR: rgb(255,128,0)">//不使用 GET/POST 变量方式
</SPAN><SPAN style="COLOR: rgb(0,0,187)">ini_set</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(221,0,0)">'session.use_trans_sid'</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(0,0,187)">0</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
</SPAN><SPAN style="COLOR: rgb(255,128,0)">//设置垃圾回收最大生存时间
</SPAN><SPAN style="COLOR: rgb(0,0,187)">ini_set</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(221,0,0)">'session.gc_maxlifetime'</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(0,0,187)">MY_SESS_TIME</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
</SPAN><SPAN style="COLOR: rgb(255,128,0)">//使用 COOKIE 保存 SESSION ID 的方式
</SPAN><SPAN style="COLOR: rgb(0,0,187)">ini_set</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(221,0,0)">'session.use_cookies'</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(0,0,187)">1</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
</SPAN><SPAN style="COLOR: rgb(0,0,187)">ini_set</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(221,0,0)">'session.cookie_path'</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(221,0,0)">'/'</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
</SPAN><SPAN style="COLOR: rgb(255,128,0)">//多主机共享保存 SESSION ID 的 COOKIE
</SPAN><SPAN style="COLOR: rgb(0,0,187)">ini_set</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(221,0,0)">'session.cookie_domain'</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(0,0,187)">$domain</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
</SPAN><SPAN style="COLOR: rgb(255,128,0)">//将 session.save_handler 设置为 user,而不是默认的 files
</SPAN><SPAN style="COLOR: rgb(0,0,187)">session_module_name</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(221,0,0)">'user'</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
</SPAN><SPAN style="COLOR: rgb(255,128,0)">//定义 SESSION 各项操作所对应的方法名:
</SPAN><SPAN style="COLOR: rgb(0,0,187)">session_set_save_handler</SPAN><SPAN style="COLOR: rgb(0,119,0)">(
array(</SPAN><SPAN style="COLOR: rgb(221,0,0)">'My_Sess'</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(221,0,0)">'open'</SPAN><SPAN style="COLOR: rgb(0,119,0)">), </SPAN><SPAN style="COLOR: rgb(255,128,0)">//对应于静态方法 My_Sess::open(),下同。
</SPAN><SPAN style="COLOR: rgb(0,119,0)">array(</SPAN><SPAN style="COLOR: rgb(221,0,0)">'My_Sess'</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(221,0,0)">'close'</SPAN><SPAN style="COLOR: rgb(0,119,0)">),
array(</SPAN><SPAN style="COLOR: rgb(221,0,0)">'My_Sess'</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(221,0,0)">'read'</SPAN><SPAN style="COLOR: rgb(0,119,0)">),
array(</SPAN><SPAN style="COLOR: rgb(221,0,0)">'My_Sess'</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(221,0,0)">'write'</SPAN><SPAN style="COLOR: rgb(0,119,0)">),
array(</SPAN><SPAN style="COLOR: rgb(221,0,0)">'My_Sess'</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(221,0,0)">'destroy'</SPAN><SPAN style="COLOR: rgb(0,119,0)">),
array(</SPAN><SPAN style="COLOR: rgb(221,0,0)">'My_Sess'</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(221,0,0)">'gc'</SPAN><SPAN style="COLOR: rgb(0,119,0)">)
);
} </SPAN><SPAN style="COLOR: rgb(255,128,0)">//end function
</SPAN><SPAN style="COLOR: rgb(0,119,0)">function </SPAN><SPAN style="COLOR: rgb(0,0,187)">open</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$save_path</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(0,0,187)">$session_name</SPAN><SPAN style="COLOR: rgb(0,119,0)">) {
return </SPAN><SPAN style="COLOR: rgb(0,0,187)">true</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
} </SPAN><SPAN style="COLOR: rgb(255,128,0)">//end function
</SPAN><SPAN style="COLOR: rgb(0,119,0)">function </SPAN><SPAN style="COLOR: rgb(0,0,187)">close</SPAN><SPAN style="COLOR: rgb(0,119,0)">() {
global </SPAN><SPAN style="COLOR: rgb(0,0,187)">$MY_SESS_CONN</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
if (</SPAN><SPAN style="COLOR: rgb(0,0,187)">$MY_SESS_CONN</SPAN><SPAN style="COLOR: rgb(0,119,0)">) { </SPAN><SPAN style="COLOR: rgb(255,128,0)">//关闭数据库连接
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$MY_SESS_CONN</SPAN><SPAN style="COLOR: rgb(0,119,0)">-></SPAN><SPAN style="COLOR: rgb(0,0,187)">Close</SPAN><SPAN style="COLOR: rgb(0,119,0)">();
}
return </SPAN><SPAN style="COLOR: rgb(0,0,187)">true</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
} </SPAN><SPAN style="COLOR: rgb(255,128,0)">//end function
</SPAN><SPAN style="COLOR: rgb(0,119,0)">function </SPAN><SPAN style="COLOR: rgb(0,0,187)">read</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$sesskey</SPAN><SPAN style="COLOR: rgb(0,119,0)">) {
global </SPAN><SPAN style="COLOR: rgb(0,0,187)">$MY_SESS_CONN</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$sql </SPAN><SPAN style="COLOR: rgb(0,119,0)">= </SPAN><SPAN style="COLOR: rgb(221,0,0)">'SELECT data FROM sess WHERE sesskey=' </SPAN><SPAN style="COLOR: rgb(0,119,0)">. </SPAN><SPAN style="COLOR: rgb(0,0,187)">$MY_SESS_CONN</SPAN><SPAN style="COLOR: rgb(0,119,0)">-></SPAN><SPAN style="COLOR: rgb(0,0,187)">qstr</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$sesskey</SPAN><SPAN style="COLOR: rgb(0,119,0)">) . </SPAN><SPAN style="COLOR: rgb(221,0,0)">' AND expiry>=' </SPAN><SPAN style="COLOR: rgb(0,119,0)">. </SPAN><SPAN style="COLOR: rgb(0,0,187)">time</SPAN><SPAN style="COLOR: rgb(0,119,0)">();
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$rs </SPAN><SPAN style="COLOR: rgb(0,119,0)">=& </SPAN><SPAN style="COLOR: rgb(0,0,187)">$MY_SESS_CONN</SPAN><SPAN style="COLOR: rgb(0,119,0)">-></SPAN><SPAN style="COLOR: rgb(0,0,187)">Execute</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$sql</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
if (</SPAN><SPAN style="COLOR: rgb(0,0,187)">$rs</SPAN><SPAN style="COLOR: rgb(0,119,0)">) {
if (</SPAN><SPAN style="COLOR: rgb(0,0,187)">$rs</SPAN><SPAN style="COLOR: rgb(0,119,0)">-></SPAN><SPAN style="COLOR: rgb(0,0,187)">EOF</SPAN><SPAN style="COLOR: rgb(0,119,0)">) {
return </SPAN><SPAN style="COLOR: rgb(221,0,0)">''</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
} else { </SPAN><SPAN style="COLOR: rgb(255,128,0)">//读取到对应于 SESSION ID 的 SESSION 数据
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$v </SPAN><SPAN style="COLOR: rgb(0,119,0)">= </SPAN><SPAN style="COLOR: rgb(0,0,187)">$rs</SPAN><SPAN style="COLOR: rgb(0,119,0)">-></SPAN><SPAN style="COLOR: rgb(0,0,187)">fields</SPAN><SPAN style="COLOR: rgb(0,119,0)">[</SPAN><SPAN style="COLOR: rgb(0,0,187)">0</SPAN><SPAN style="COLOR: rgb(0,119,0)">];
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$rs</SPAN><SPAN style="COLOR: rgb(0,119,0)">-></SPAN><SPAN style="COLOR: rgb(0,0,187)">Close</SPAN><SPAN style="COLOR: rgb(0,119,0)">();
return </SPAN><SPAN style="COLOR: rgb(0,0,187)">$v</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
} </SPAN><SPAN style="COLOR: rgb(255,128,0)">//end if
</SPAN><SPAN style="COLOR: rgb(0,119,0)">} </SPAN><SPAN style="COLOR: rgb(255,128,0)">//end if
</SPAN><SPAN style="COLOR: rgb(0,119,0)">return </SPAN><SPAN style="COLOR: rgb(221,0,0)">''</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
} </SPAN><SPAN style="COLOR: rgb(255,128,0)">//end function
</SPAN><SPAN style="COLOR: rgb(0,119,0)">function </SPAN><SPAN style="COLOR: rgb(0,0,187)">write</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$sesskey</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(0,0,187)">$data</SPAN><SPAN style="COLOR: rgb(0,119,0)">) {
global </SPAN><SPAN style="COLOR: rgb(0,0,187)">$MY_SESS_CONN</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$qkey </SPAN><SPAN style="COLOR: rgb(0,119,0)">= </SPAN><SPAN style="COLOR: rgb(0,0,187)">$MY_SESS_CONN</SPAN><SPAN style="COLOR: rgb(0,119,0)">-></SPAN><SPAN style="COLOR: rgb(0,0,187)">qstr</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$sesskey</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$expiry </SPAN><SPAN style="COLOR: rgb(0,119,0)">= </SPAN><SPAN style="COLOR: rgb(0,0,187)">time</SPAN><SPAN style="COLOR: rgb(0,119,0)">() + </SPAN><SPAN style="COLOR: rgb(0,0,187)">My_SESS_TIME</SPAN><SPAN style="COLOR: rgb(0,119,0)">; </SPAN><SPAN style="COLOR: rgb(255,128,0)">//设置过期时间
//写入 SESSION
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$arr </SPAN><SPAN style="COLOR: rgb(0,119,0)">= array(
</SPAN><SPAN style="COLOR: rgb(221,0,0)">'sesskey' </SPAN><SPAN style="COLOR: rgb(0,119,0)">=> </SPAN><SPAN style="COLOR: rgb(0,0,187)">$qkey</SPAN><SPAN style="COLOR: rgb(0,119,0)">,
</SPAN><SPAN style="COLOR: rgb(221,0,0)">'expiry' </SPAN><SPAN style="COLOR: rgb(0,119,0)">=> </SPAN><SPAN style="COLOR: rgb(0,0,187)">$expiry</SPAN><SPAN style="COLOR: rgb(0,119,0)">,
</SPAN><SPAN style="COLOR: rgb(221,0,0)">'data' </SPAN><SPAN style="COLOR: rgb(0,119,0)">=> </SPAN><SPAN style="COLOR: rgb(0,0,187)">$data</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$MY_SESS_CONN</SPAN><SPAN style="COLOR: rgb(0,119,0)">-></SPAN><SPAN style="COLOR: rgb(0,0,187)">Replace</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(221,0,0)">'sess'</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(0,0,187)">$arr</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(221,0,0)">'sesskey'</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(0,0,187)">$autoQuote </SPAN><SPAN style="COLOR: rgb(0,119,0)">= </SPAN><SPAN style="COLOR: rgb(0,0,187)">true</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
return </SPAN><SPAN style="COLOR: rgb(0,0,187)">true</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
} </SPAN><SPAN style="COLOR: rgb(255,128,0)">//end function
</SPAN><SPAN style="COLOR: rgb(0,119,0)">function </SPAN><SPAN style="COLOR: rgb(0,0,187)">destroy</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$sesskey</SPAN><SPAN style="COLOR: rgb(0,119,0)">) {
global </SPAN><SPAN style="COLOR: rgb(0,0,187)">$MY_SESS_CONN</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$sql </SPAN><SPAN style="COLOR: rgb(0,119,0)">= </SPAN><SPAN style="COLOR: rgb(221,0,0)">'DELETE FROM sess WHERE sesskey=' </SPAN><SPAN style="COLOR: rgb(0,119,0)">. </SPAN><SPAN style="COLOR: rgb(0,0,187)">$MY_SESS_CONN</SPAN><SPAN style="COLOR: rgb(0,119,0)">-></SPAN><SPAN style="COLOR: rgb(0,0,187)">qstr</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$sesskey</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$rs </SPAN><SPAN style="COLOR: rgb(0,119,0)">=& </SPAN><SPAN style="COLOR: rgb(0,0,187)">$MY_SESS_CONN</SPAN><SPAN style="COLOR: rgb(0,119,0)">-></SPAN><SPAN style="COLOR: rgb(0,0,187)">Execute</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$sql</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
return </SPAN><SPAN style="COLOR: rgb(0,0,187)">true</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
} </SPAN><SPAN style="COLOR: rgb(255,128,0)">//end function
</SPAN><SPAN style="COLOR: rgb(0,119,0)">function </SPAN><SPAN style="COLOR: rgb(0,0,187)">gc</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$maxlifetime </SPAN><SPAN style="COLOR: rgb(0,119,0)">= </SPAN><SPAN style="COLOR: rgb(0,0,187)">null</SPAN><SPAN style="COLOR: rgb(0,119,0)">) {
global </SPAN><SPAN style="COLOR: rgb(0,0,187)">$MY_SESS_CONN</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$sql </SPAN><SPAN style="COLOR: rgb(0,119,0)">= </SPAN><SPAN style="COLOR: rgb(221,0,0)">'DELETE FROM sess WHERE expiry<' </SPAN><SPAN style="COLOR: rgb(0,119,0)">. </SPAN><SPAN style="COLOR: rgb(0,0,187)">time</SPAN><SPAN style="COLOR: rgb(0,119,0)">();
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$MY_SESS_CONN</SPAN><SPAN style="COLOR: rgb(0,119,0)">-></SPAN><SPAN style="COLOR: rgb(0,0,187)">Execute</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$sql</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
</SPAN><SPAN style="COLOR: rgb(255,128,0)">//由于经常性的对表 sess 做删除操作,容易产生碎片,
//所以在垃圾回收中对该表进行优化操作。
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$sql </SPAN><SPAN style="COLOR: rgb(0,119,0)">= </SPAN><SPAN style="COLOR: rgb(221,0,0)">'OPTIMIZE TABLE sess'</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$MY_SESS_CONN</SPAN><SPAN style="COLOR: rgb(0,119,0)">-></SPAN><SPAN style="COLOR: rgb(0,0,187)">Execute</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$sql</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
return </SPAN><SPAN style="COLOR: rgb(0,0,187)">true</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
} </SPAN><SPAN style="COLOR: rgb(255,128,0)">//end function
</SPAN><SPAN style="COLOR: rgb(0,119,0)">} </SPAN><SPAN style="COLOR: rgb(255,128,0)">///:~
//使用 ADOdb 作为数据库抽象层。
</SPAN><SPAN style="COLOR: rgb(0,119,0)">require_once(</SPAN><SPAN style="COLOR: rgb(221,0,0)">'adodb/adodb.inc.php'</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
</SPAN><SPAN style="COLOR: rgb(255,128,0)">//数据库配置项,可放入配置文件中(如:config.inc.php)。
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$db_type </SPAN><SPAN style="COLOR: rgb(0,119,0)">= </SPAN><SPAN style="COLOR: rgb(221,0,0)">'mysql'</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$db_host </SPAN><SPAN style="COLOR: rgb(0,119,0)">= </SPAN><SPAN style="COLOR: rgb(221,0,0)">'192.168.212.1'</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$db_user </SPAN><SPAN style="COLOR: rgb(0,119,0)">= </SPAN><SPAN style="COLOR: rgb(221,0,0)">'sess_user'</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$db_pass </SPAN><SPAN style="COLOR: rgb(0,119,0)">= </SPAN><SPAN style="COLOR: rgb(221,0,0)">'sess_pass'</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$db_name </SPAN><SPAN style="COLOR: rgb(0,119,0)">= </SPAN><SPAN style="COLOR: rgb(221,0,0)">'sess_db'</SPAN><SPAN style="COLOR: rgb(0,119,0)">;
</SPAN><SPAN style="COLOR: rgb(255,128,0)">//创建数据库连接,这是一个全局变量。
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$GLOBALS</SPAN><SPAN style="COLOR: rgb(0,119,0)">[</SPAN><SPAN style="COLOR: rgb(221,0,0)">'MY_SESS_CONN'</SPAN><SPAN style="COLOR: rgb(0,119,0)">] =& </SPAN><SPAN style="COLOR: rgb(0,0,187)">ADONewConnection</SPAN><SPAN style="COLOR: rgb(0,119,0)">(</SPAN><SPAN style="COLOR: rgb(0,0,187)">$db_type</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
</SPAN><SPAN style="COLOR: rgb(0,0,187)">$GLOBALS</SPAN><SPAN style="COLOR: rgb(0,119,0)">[</SPAN><SPAN style="COLOR: rgb(221,0,0)">'MY_SESS_CONN'</SPAN><SPAN style="COLOR: rgb(0,119,0)">]-></SPAN><SPAN style="COLOR: rgb(0,0,187)">Connect</SPAN><SPAN style="COLOR: rgb(0,119,0)">( </SPAN><SPAN style="COLOR: rgb(0,0,187)">$db_host</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(0,0,187)">$db_user</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(0,0,187)">$db_pass</SPAN><SPAN style="COLOR: rgb(0,119,0)">, </SPAN><SPAN style="COLOR: rgb(0,0,187)">$db_name</SPAN><SPAN style="COLOR: rgb(0,119,0)">);
</SPAN><SPAN style="COLOR: rgb(255,128,0)">//初始化 SESSION 设置,必须在 session_start() 之前运行!!
</SPAN><SPAN style="COLOR: rgb(0,0,187)">My_Sess</SPAN><SPAN style="COLOR: rgb(0,119,0)">::</SPAN><SPAN style="COLOR: rgb(0,0,187)">init</SPAN><SPAN style="COLOR: rgb(0,119,0)">();
</SPAN><SPAN style="COLOR: rgb(0,0,187)">?></SPAN>
</SPAN>
</CODE>登录后复制