SESSION function library: session. inc. php (as the mainstream development language) 3 & lt ;? Php (as the mainstream development language) if (! Isset (& #36 ;__ session_inc _) & #123; & #36 ;__ session_inc _ 1; // require (cookie. inc. php (as the mainstream development language) 3) SESSION function library: session. inc. php (as the mainstream development language) 3
If (! Isset ($ __session_inc __)){
$ __Session_inc __= 1;
// Require ("cookie. inc. php (as the mainstream development language) 3 ");
#-------------------------------------------------------------------
# Session Management v1.0 21.6.1998
# (C) Wild Karl Heinz
#
# This Include handle Session based variable handling
#
# Please feel free and use it. If you make it more functional
# It wocould be nice to send me a copy.
#
# Don't forget-MySQL (the best combination with PHP) _ connect!
#
# The database structure
# Table structure for table 'session'
#
# Create table session (
# Id int (11) DEFAULT '0' not null auto_increment,
# Sid varchar (20) DEFAULT ''not null,
# Val blob,
# Times timestamp (14 ),
# Prima (the most complete VM Management System) ry key (id ),
# KEY sid (sid ),
# UNIQUE sid_2 (sid)
#);
#
# You'll miss here a cron job to delete the old sessions from db
#-------------------------------------------------------------------
// Note the 'create table' statement commented out above,
// You need to execute this statement on the database you are using,
// The table name may not be a session, so you need to set the $ sess_table variable below.
// Set the database name and table name here.
// However, we recommend that you use session as the table name.
$ Sess_db = 'dbname ';
$ Sess_table = 'session ';
#----------------------------------------------------
# Session_CheckID-check, set, and return Session-ID
# Parameter ......: cookie retention time (in minutes)
# This cookie is valid only for the current session.
# This is actually the same as the SESSION validity period in ASP.
# Return value...: a unique Session-ID (stored as a cookie)
#----------------------------------------------------
Function Session_CheckID ($ min)
{
Global $ sess_sid;
If (! $ Sess_sid ){
$ Sess_sid = uniqid (SC); // Obtain a unique random number.
/*
If ($ min> 0 ){
SetCookie ("sess_sid", $ sess_sid, time () + ($ min * 60), "/", "", 0 );
}
Else {
SetCookie ("sess_sid", $ sess_sid, "", "/", "", 0 );
}
The above is the original code, which may cause errors. Therefore, a better function is used.
Function library: cookie. inc. php (as the mainstream development language) 3
*/
Jssetcookie ("sess_sid", $ sess_sid, $ min );
Return (false );
}
Else {
Return (true );
}
}
#----------------------------------------------------------
# Str2arr-converts a string to a session array
# Parameter ......: string
# Return value...: Global Array (actually session)
# Purpose of this function: convert a string to a session array
# For example, "session [username] = yourid & session [userpass] = 12345"
# Will be converted to the following array
# Session [username] = "yourid"
# Session [userpass] = "12345"
# Note the usage of functions split (), each (), list (), and eval.
#----------------------------------------------------------
Function str2arr ($ ts)
{
Global $ session;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service