<?php
/**
* 文件名:session.class.php 
* 功能:SESSION处理文件 
* 建立日期:2008-10-08
*/
if(defined(MYTHINK)){
exit('无法访问此页面');
}class session{function __construct(){
//ob_start();if (!defined(SESSIONSTARTED)){
ini_set('session.save_handler', 'user'); 
session_set_save_handler(array($this,"on_session_start"),array($this,"on_session_end"),array($this,"on_session_read"),array($this,"on_session_write"),array($this,"on_session_destroy"),array($this,"on_session_gc")); 
//session_set_save_handler("on_session_start","on_session_end","on_session_read","on_session_write","on_session_destroy","on_session_gc");@session_start();
define('SESSIONSTARTED',true)}
}
function on_session_start(){
$this->db = new db_mysql();
return true;
}function on_session_end(){
$this->db->close();
return true; 
}function on_session_read($key){
$ses_val = $this->db->fetch_array($this->db->query("SELECT * FROM `think_session` WHERE ses_id = '{$key}'"));
return $ses_val;}function on_session_write($key,$val){
$this->db->query("INSERT INTO `think_session`(`ses_id`,`ses_type`,`ses_date`) VALUE ('{$key}',{$val},now())");}function on_session_destroy($key){
$this->db->query("DELETE FROM `think_session` WHERE ses_id = '{$key}'");
return true;
}function on_session_gc(){
//$this->db->query("DELETE FROM `think_session` WHERE ses_id = '{$key}'");
return true;
}
}
?>