时间:2021-07-01 10:21:17 帮助过:4人阅读
{$time}"; $result = mysql_query($sql, $link); if(@$row = mysql_fetch_row($result, $link)) { return $row[0]; }else { return ''; } } function write($sessionId, $sessionData) { global $link, $expiry; $sessionId = mysql_escape_string($sessionId); $sessionData = mysql_escape_string($sessionData); $time = time() + $expiry; $sql = "INSERT INTO session(session_id, value, expiry) VALUES('{$sessionId}', '{$sessionData}', {$time});"; $result = mysql_query($sql, $link); if($result) { return true; } $sql = "UPDATE session SET value='{$sessionData}', expiry={$time} WHERE session_id='{$sessionId}'"; $result = mysql_query($sql, $link); if($result && mysql_affected_rows($link)) { return true; }else { return false; } } function destroy($sessionId) { global $link; $sessionId = mysql_escape_string($sessionId); $sql = "DELETE FROM session WHERE session_id='{$sessionId}';"; $result = mysql_query($sql, $link); if($result) { return true; }else { return false; } } function gc($maxLifeTime) { return true; }