PHP Tutorial The session variable is used to store information about the user session, or to change the settings of the user session. The information held by the session variable is specific to a single user and is available to all pages in the application.
php session variable
When you run an application, you open it, make changes, and then close it. It's a lot like a session. The computer knows who you are. It knows when you start the application and when it terminates it. But on the Internet, there's a problem: the server doesn't know who you are and what you do, and this is because http addresses cannot maintain state.
PHP session solves this problem by storing user information on the server for subsequent use (such as user name, purchased items, etc.). However, session information is temporary and will be deleted after the user leaves the site. If you need to store information permanently, you can store the data in a database tutorial.
The working mechanism of session is to create a unique id (uid) for each visitor and store variables based on this uid. The uid is stored in a cookie or transmitted through the 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();
}
}