php自定义发送Session会话id,PHP–会话–session-自定义

class FileSessionHandler

{

private $savePath;

function open($savePath, $sessionName)

{

$this->savePath = $savePath;

if (!is_dir($this->savePath)) {

mkdir($this->savePath, 0777);

}

return true;

}

function close()

{

return true;

}

function read($id)

{

return (string)@file_get_contents("$this->savePath/sess_$id");

}

function write($id, $data)

{

return file_put_contents("$this->savePath/sess_$id", $data) === false ? false : true;

}

function destroy($id)

{

$file = "$this->savePath/sess_$id";

if (file_exists($file)) {

unlink($file);

}

return true;

}

function gc($maxlifetime)

{

foreach (glob("$this->savePath/sess_*") as $file) {

if (filemtime($file) + $maxlifetime < time() && file_exists($file)) {

unlink($file);

}

}

return true;

}

}

$handler = new FileSessionHandler();

session_set_save_handler(

array($handler, 'open'),

array($handler, 'close'),

array($handler, 'read'),

array($handler, 'write'),

array($handler, 'destroy'),

array($handler, 'gc')

);

// the following prevents unexpected effects when using objects as save handlers

register_shutdown_function('session_write_close');

session_start();

// proceed to set and retrieve values by key from $_SESSION

which will be available after two weeks

porno The Proper Wedding Etiquette For Tipping Page 1 of 2

While we’d love to see products launch without a hitch

pornoFashion For Your Strawberry Shape

php-%E4%BC%9A%E8%AF%9D-session-%E8%87%AA%E5%AE%9A%E4%B9%89

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值