files: ?> if (!isset($include_path)) $include_path = ; if (!is_array($database)) $DBsess = $database[DBTYPE]["session"]; $SESS_LIFE = get_cfg_var("session.gc_maxlifetime"); function sess_open($path, $name) function sess_close() function sess_read($id) function sess_write($id, $data) $expiry_time = time() + $SESS_LIFE; if ( !get_magic_quotes_gpc() ) $now = time(); $result = mysql_query("INSERT into `sessions` (`id`, `expiry_time`, `data`)", $DBsess_link); if ( !$result ) return $result; function sess_destroy($id) function sess_gc($maxlifetime) } session_module_name(); ?> session_start(); $_SESSION["abc"] = "A: I will be back!"; ?> get_session_test.php session_start(); ?> session_start();
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
{
include ($include_path."common/Common.config.php");
}
$DBsess_link = mysql_connect($DBsess["host"], $DBsess["user"], $DBsess["password"])
or die ("Error:Can not connect to Mysql server.");
{
return true;
}
{
return true;
}
{
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;
}
{
global $DBsess , $DBsess_link, $SESS_LIFE;
mysql_select_db($DBsess["dbname"]);
{
$data = addslashes($data);
}
{
$result = mysql_query("UPDATE `sessions` SET `data`=$data, `expiry_time`=$expiry_time
WHERE `id` = $id AND `expiry_time` > $now", $DBsess_link);
}
}
{
global $DBsess , $DBsess_link;
mysql_select_db($DBsess["dbname"]);
$query = mysql_query("DELETE FROM `session` WHERE `id`=$id");
return $query;
}
{
global $DBsess , $DBsess_link;
$query = mysql_query("DELETE FROM `sessions` WHERE `expiry_time` return mysql_affected_rows($DBsess_link);
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["meto"] = "B: Me too ";
echo "click me";
// test for using session
include ("common/Common.config.php");
include ("include/session.inc.php");
/*
* www.knowsky.com
*/
$_SESSION["c"] = "
C: I will follow U. ^0^!";
print($_SESSION["abc"]);
print("
");
print($_SESSION["meto"]);
echo "
".
"click again";
get_session_test2.php
//get_session_test2.php
// test for using session
include ("common/Common.config.php");
include ("include/session.inc.php");
print($_SESSION["c"]);
?>

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

SublimeText3 English version
Recommended: Win version, supports code prompts!

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function