/ Published in: PHP
Easy and lazy way to use session in PHP5
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
class Session { var $__setting; function __construct($name = 'FuseLogic') { $this->__setting = new open(); $this->__setting->name = $name; $this->__setting->space = '___'; { foreach($_SESSION as $name => $value) { if($temp[0] == $this->__setting->name) { $this->__setting->_session[$name] = $value; } } } } private function name($name = null) { return $this->__setting->name.$this->__setting->space.$name; } public function __get($name) { return @$this->__setting->_session[$name]; } public function __set($name,$value) { $this->__setting->_session[$name] = $value; $name = $this->name($name); $_SESSION[$name] = $value; } public function __isset($name) { } function clean() { { foreach($this->__setting->_session as $name => $value) { $name = $this->name($name); } } } function destroy() { } function fromArray($a=null) { { foreach($a as $k => $v) $this->$k = $v; } } function toArray() { return $this->__setting->_session; } }