自定session保存路径 删除,注销,写入函数 |
时间:2015-01-23 来源:西部数据 作者:西部数据 |
|
- */
- $sessionpath=session_save_path();
- echo $sessionpath;
- if(strpos($sessionpath,";")!==false)
- {
- $sessionpath=substr($sessionpath,strpos($sessionpath,";")+1);
- }
-
-
- function open($save_path,$session_name)
- {
- global $sess_save_path,$sess_session_name;
- $sess_save_path=$save_path;
- $sess_session_name=$session_name;
- return(true);
- }
- function close()
- {
- return(true);
- }
- function read($id)
- {
- global $sess_save_path,$sess_session_name;
- $sess_file="$sess_save_path/sess_$id";
- if($fp=@fopen($sess_file,"r"))
- {
- $sess_data=fread($fp,filesize($sess_file));
- return($sess_data);
- }
- else
- {
- return("");
- }
- }
- function write($id,$sess_data)
- {
- global $sess_save_path,$sess_session_name;
- $sess_file="$sess_save_path/sess_$id";
- if($fp=@fopen($sess_file,"w"))
- {
- return(fwrite($fp,$sess_data));
- }
- else
- {
- return(false);
- }
- }
- function destroy($id)
- {
- global $sess_save_path,$sess_session_name;
- $sess_file="$sess_save_path/sess_$id";
- return(@unlink($sess_file));
- }
- function gc($maxlifetime)
- {
- return true;
- }
- session_set_save_handler("open","close","read","write","destroy","gc");
- session_start();
-
|
|
|
|