A very basic SESSION management class in singleton mode.
<?php class session { const SESSION_STARTED = TRUE; const SESSION_NOT_STARTED = FALSE; private $session_state = self::SESSION_NOT_STARTED; private static $instance; public static function get_instance(){ if(!isset(self::$instance)){ self::$instance = new self; } self::$instance->start_session(); return self::$instance; } public function start_session(){ if($this->session_state == self::SESSION_NOT_STARTED){ $this->session_state = session_start(); } return $this->session_state; } public function __set($name,$value){ $_SESSION[$name] = $value; } public function __get($name){ if(isset($_SESSION[$name])){ return $_SESSION[$name]; } } public function __isset($name){ return isset($_SESSION[$name]); } public function __unsset($name){ unset($_SESSION[$name]); } public function destroy(){ if($this->session_state == self::SESSION_STARTED){ $this->session_state = !session_destroy(); unset($_SESSION); return !$this->session_state; } return false; } }
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
How to fix KB5055523 fails to install in Windows 11?
3 weeks agoByDDD
How to fix KB5055518 fails to install in Windows 10?
3 weeks agoByDDD
Roblox: Dead Rails - How To Tame Wolves
1 months agoByDDD
Strength Levels for Every Enemy & Monster in R.E.P.O.
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Roblox: Grow A Garden - Complete Mutation Guide
2 weeks agoByDDD

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

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

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.
