PHP Tutorial Session variables are used to store information about a user's session, or to change settings for a user session. The session variable holds information that is single-user and can be used by all pages in the application.
PHP Session Variables
When you run an application, you open it, make some changes, and then close it. It's like a conversation. The computer knows who you are. It knows when you start the application and when it terminates. But on the internet, there is a problem: the server does not know who you are and what you do, because the HTTP address does not maintain state.
By storing user information on the server for later use, the PHP session solves the problem (such as user name, purchase of goods, etc.). However, the session information is temporary and will be deleted when the user leaves the site. If you need to store information permanently, you can store the data in a database tutorial.
The session works by creating a unique ID (UID) for each visitor and storing the variables based on this UID. The UID is stored in a cookie or transmitted through a URL.
*/
Class My_session
{
function My_session ()
{
Destroy sessions started with Session.auto_start
if (session_id ())
{
Session_unset ();
Session_destroy ();
}
Session_Start ();
}
function set ($name, $value)
{
$_session[$name] = $value;
}
function Get ($name)
{
if (Isset ($_session[$name]))
return $_session[$name];
Else
return false;
}
Function del ($name)
{
Unset ($_session[$name]);
}
function Destroy ()
{
$_session = Array ();
Session_destroy ();
}
}
http://www.bkjia.com/PHPjc/631711.html www.bkjia.com true http://www.bkjia.com/PHPjc/631711.html techarticle PHP Tutorial Session variables are used to store information about a user's session, or to change settings for a user session. The session variable holds information that is single-user and is available to the application in ...