我收到:
警告:session_start():无法读取会话数据:user (路径:C:\ xampp \ tmp)在 C:\ xampp \ htdocs \ index.php 上线 6
当我尝试使用session_start时。 我无法为会话分配值并读取它。任何想法?
<?php
GLOBAL $mysqli_link;
session_write_close();
function _open($save_path, $session_name) {
return true;
}
function _close() {
return true;
}
function _read($id) {
GLOBAL $mysqli_link;
//$id = hash('sha512', $id);
$stmt = $mysqli_link->prepare("SELECT data FROM session WHERE id = ? limit 1");
$stmt->bind_param('s', $id);
$stmt->execute();
$stmt->bind_result($data);
$stmt->fetch();
$stmt->close();
if (isset($data)) {
return $data;
}
else{
return false;
}
}
function _write($id, $dataw) {
GLOBAL $mysqli_link;
//$id = hash('sha512', $id);
$access = date ("ymdHis");
if($dataw!=""){
$stmt = $mysqli_link->prepare("REPLACE INTO session VALUES (?,?,?)");
$stmt->bind_param('sss', $id, $access, $dataw);
$stmt->execute();
$stmt->close();
}
return true;
}
function _destroy($id) {
GLOBAL $mysqli_link;
//$id = hash('sha512', $id);
$stmt = $mysqli_link->prepare("DELETE FROM session WHERE id = ?");
$stmt->bind_param('s', $id);
$stmt->execute();
$stmt->close();
}
function _clean($max) {
GLOBAL $mysqli_link;
$access = date ("YmdHis");
$stmt = $mysqli_link->prepare("DELETE FROM session WHERE access < DATE_SUB('$access', INTERVAL 3 hour)");
$stmt->execute();
$stmt->close();
return true;
}
session_set_save_handler('_open','_close','_read','_write','_destroy','_clean');
register_shutdown_function('session_write_close');
?>
我的功能可能有问题吗?