[Php]再冲动下发个SessionHandle[memcache实现]

澳门新葡亰3522平台游戏,?php/***session处理器*memcache实现*@authorMoXieSysTem128@GMail.Com*/classSessionHandlerextendsMemcache{public$_sessionId;#session编号public$_sessionExpire;#session过期时间public$_sessionIsQuery;publicfunction__construct(){$this-_sessionExpire=600;$this-connect(”localhost”,11211);}/***获取所有定位字段**//***读取Session**@returnunknown*/publicfunctiongetSession($snKey){$returnInfo=$this-get($snKey);$this-_sessionIsQuery=(bool)$returnInfo;return$returnInfo;}/***插入新的Session*/publicfunctioninsertSession($snKey,$value){return$this-set($snKey,$value,0,$this-_sessionExpire);}/***更新session信息**@returnunknown*/publicfunctionupdateSession($snKey,$value){#修改语句return$this-set($snKey,$value,0,$this-_sessionExpire);}/***删除Session**@returnunknown*/publicfunctiondelSession($snKey){return$this-delete($snKey,0);}/***删除过期Session**@returnunknown*/publicfunctionexpireSession(){returntrue;}/***session启动器**/publicfunctionon_session_start(){$this-_sessionSite=1;$this-_sessionId=session_id();returntrue;}/***session终止*/publicfunctionon_session_end(){return$this-expireSession();}/***读取方法**@paramunknown_type$key*/publicfunctionon_session_read($key){return$this-getSession($key);}/***写入方法**@paramunknown_type$key*@paramunknown_type$value*/publicfunctionon_session_write($key,$value){$this-getSession($key);if($this-_sessionIsQuery){$this-updateSession($key,$value);}else{$this-insertSession($key,$value);}returntrue;}/***销毁方法**@paramunknown_type$key*/publicfunctionon_session_destroy($key){return$this-delSession();}/***过期方法**@paraminteger$maxLifeTime*/publicfunctionon_session_gc($maxLifeTime){return$this-expireSession();}}$sessionHandler=newSessionHandler();session_set_save_handler(array($sessionHandler,”on_session_start”),array($sessionHandler,”on_session_end”),array($sessionHandler,”on_session_read”),array($sessionHandler,”on_session_write”),array($sessionHandler,”on_session_destroy”),array($sessionHandler,”on_session_gc”));unregister_tick_function(”session_write_close”);session_start();//$_SESSION[”MoXie”]=”Wonderfull!”;//$_SESSION[”SysTem128”]=”Wonderfull!”;//session_unregister(”MoXie”);print_r($_SESSION);?