注册 | 登录
欢迎注册会员

当前位置:首页 > 狗万 怎么玩 > PHP技术 > 正文

Php中session_set_save_handler的含义

来源:程序人生 【 】 浏览:608 添加日期:2016-09-16 22:46:05 我要评论(0)

今天看手册,无意中看到了session_set_save_handler不解其意,于是上网搜寻得知,可以使用session_set_save_handler函数重载SESSION存储方式存储于MYSQL,样例如下:


?"?.?time();?
????????$Result?=?mysql_query($Query,?$DB_SELECT_DB);?
???
??if?(list($SessionArray)?=?mysql_fetch_row($Result))?{?
??return?$SessionArray;?
??}?
???
??return?false;?
??}?
???
??function?sess_write($SessionKey,?$VArray)?{?
??global?$DB_SELECT_DB,?$SESS_LIFE;?
???
??$SessionExpTime?=?time()?+?$SESS_LIFE;?
??$SessionArray?=?addslashes($VArray);?
???
??$Query?=?"INSERT?INTO?cdb_global_sessions?(SessionKey,SessionExpTime,SessionArray)?VALUES?('".$SessionKey."','".$SessionExpTime."','".$SessionArray."')";?
??$Result?=?mysql_query($Query,?$DB_SELECT_DB);?
???
??if?(!$Result){?
??$Query?=?"UPDATE?cdb_global_sessions?SET?SessionExpTime?=?'".$SessionExpTime."',?SessionArray?=?'".$SessionArray."'?WHERE?SessionKey?=?'".$SessionKey."'?AND?SessionExpTime?>?"?.?time();?
??$Result?=?mysql_query($Query,?$DB_SELECT_DB);?
??}????
??return?$Result;?
??}?
???
??function?sess_destroy($SessionKey)?{?
??global?$DB_SELECT_DB;?
???
??$Query?=?"DELETE?FROM?cdb_global_sessions?WHERE?SessionKey?=?'".$SessionKey."'";?
??$Result?=?mysql_query($Query,?$DB_SELECT_DB);?
???
??return?$Result;?
??}?
???
??function?sess_gc($maxlifetime)?{?
??global?$DB_SELECT_DB;?
???
??$Query?=?"DELETE?FROM?cdb_global_sessions?WHERE?SessionExpTime?



你浏览的文章是 - 《Php中session_set_save_handler的含义》!
文章出处:https://www.procedurelife.com/content/akkjhk.html
0% (0)
0% (0)
评论0
头像 游客
1 2