* merge ztSessionHandler.

This commit is contained in:
wangyidong
2022-11-10 15:47:05 +08:00
parent e8f50c14c6
commit 6eae8345f7
4 changed files with 27 additions and 22 deletions
+7 -6
View File
@@ -3265,13 +3265,13 @@ class ztSessionHandler
$sessFile = $this->getSessionFile($id);
if(md5_file($sessFile) == md5($sessData)) return true;
if(file_put_contents($sessFile, $sessData))
if(file_put_contents($sessFile, $sessData, LOCK_EX))
{
if(!file_exists($this->rawFile)) touch($this->rawFile);
touch($this->rawFile);
if(strpos($sessData, 'user|') !== false)
{
$rawSessContent = (string) file_get_contents($this->rawFile);
if(strpos($rawSessContent, 'user|') === false) file_put_contents($this->rawFile, $sessData);
$rawSessContent = (string) file_get_contents($this->rawFile, false, null, 0, 1024 * 2);
if(strpos($rawSessContent, 'user|') === false) file_put_contents($this->rawFile, $sessData, LOCK_EX);
}
return true;
@@ -3290,9 +3290,10 @@ class ztSessionHandler
public function destroy($id)
{
$sessFile = $this->getSessionFile($id);
unlink($sessFile);
unlink($this->rawFile);
if(file_exists($sessFile)) unlink($sessFile);
if(file_exists($this->rawFile)) unlink($this->rawFile);
touch($sessFile);
touch($this->rawFile);
return true;
}