files:
common/Common.config.php
include/session.inc.php
session_test.php
get_session_test.php
get_session_test2.php
Common.config.php
/*
* Common config
* By 恋太后天
*/
/*
* Database config
*/
define( "DBTYPE", "mysql" );
$database = array
(
"mysql" => array
(
"default" => array
(
"host" => "localhost",
"user" => "root",
"password" => "",
"dbname" => ""
),
"session" => array
(
"host" => "localhost",
"user" => "session",
"password" => "session",
"dbname" => "sessions"
)
)
);
?>
session.inc.php
//使用mysql存放session 函数表
// by 恋太后天 2005-4-28
if (!isset($include_path)) $include_path = '';
if (!is_array($database))
{
include ($include_path."common/Common.config.php");
}
$DBsess = $database[DBTYPE]["session"];
$DBsess_link = mysql_connect($DBsess["host"], $DBsess["user"], $DBsess["password"])
or die ("Error:Can not connect to Mysql server.");
$SESS_LIFE = get_cfg_var("session.gc_maxlifetime");
function sess_open($path, $name)
{
return true;
}
function sess_close()
{
return true;
}
function sess_read($id)
{
global $DBsess , $DBsess_link;
mysql_select_db($DBsess["dbname"]);
$now = time();
$result = mysql_query("SELECT `data` FROM `sessions`
WHERE `id`= '$id' AND `expiry_time` > $now", $DBsess_link);
if (list($data) = mysql_fetch_row($result))
{
return $data;
}
return false;
}
function sess_write($id, $data)
{
global $DBsess , $DBsess_link, $SESS_LIFE;
mysql_select_db($DBsess["dbname"]);
$expiry_time = time() + $SESS_LIFE;
if ( !get_magic_quotes_gpc() )
{
$data = addslashes($data);
}
$now = time();
$result = mysql_query("INSERT into `sessions` (`id`, `expiry_time`, `data`)", $DBsess_link);
if ( !$result )
{
$result = mysql_query("UPDATE `sessions` SET `data`='$data', `expiry_time`=$expiry_time
WHERE `id` = '$id' AND `expiry_time` > $now", $DBsess_link);
}
return $result;
}
function sess_destroy($id)
{
global $DBsess , $DBsess_link;
mysql_select_db($DBsess["dbname"]);
$query = mysql_query("DELETE FROM `session` WHERE `id`='$id'");
return $query;
}
function sess_gc($maxlifetime)
{
global $DBsess , $DBsess_link;
$query = mysql_query("DELETE FROM `sessions` WHERE `expiry_time` return mysql_affected_rows($DBsess_link);
}
session_module_name();
session_set_save_handler("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc");
?>
session_test.php
// test for using session
include ("common/Common.config.php");
include ("include/session.inc.php");
session_start();
$_SESSION["abc"] = "A: I will be back!";
$_SESSION["meto"] = "B: Me too ";
echo "
?>
get_session_test.php
// test for using session
include ("common/Common.config.php");
include ("include/session.inc.php");
session_start();
/*
* www.knowsky.com
*/
$_SESSION["c"] = "
C: I will follow U. ^0^!";
print($_SESSION["abc"]);
print("
");
print($_SESSION["meto"]);
echo "
".
"
?>
get_session_test2.php
//get_session_test2.php
// test for using session
include ("common/Common.config.php");
include ("include/session.inc.php");
session_start();
print($_SESSION["c"]);
?>

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
