📄 sessionmodel.php
字号:
<?php
/*
http://www.vodcms.com
vodcms6.0
qq:24498936
msn:jdzcn_net@hotmail.com
Session存储方案定义
采用mysql保存session数据.
*/
class SessionModel extends Easy_Session_File{
protected static $table;
public function init(){
$this->start();
}
/*
read 取seesion数据
*/
public function read($sid){
if($sid){
$select = $this->_DB->select();
$select->from(self::$table, 'session');
$select->where("`sid`='$sid'");
$select->limit(1);
$sql = $select->toString();
$result = $this->_DB->fetRow($sql);
return $result['session'];
}else{
return false;
}
}
/*
Session写入
@param $sid sesssion_id
@param $data 数据库值
*/
public function write($sid, $data){
$array = null;
$select = $this->_DB->select();
$select->from(self::$table, 'sid');
$select->where("`sid`='$sid'");
$select->limit(1);
$sql = $select->toString();
$result = $this->_DB->fetRow($sql);
if ($result == false){
$array['sid'] = $sid;
$array['session'] = $data;
$array['userip'] = $_SERVER['REMOTE_ADDR'];
$array['lastime'] = time();
$array['firstime'] = time();
$this->_DB->insert(self::$table, $array);
}else{
$array = array();
$array['session'] = $data;
$array['userip'] = $_SERVER['REMOTE_ADDR'];
$array['lastime'] = time();
$this->_DB->update(self::$table, $array, array('sid'=>$sid));
}
unset($array);
}
/*
注销
*/
function destroy(){
}
function __destruct()
{
//session_write_close();
}
public function gc(){
$lifetime = 3600;
$time = time();
$this->_DB->delete(self::$table, 'lastime>firstime-'.$time);
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -