- Seme Framework
- versi 4.0.3 (ID)
- Persyaratan
- Download & Install
- Pengaturan
- Tutorial
- Perutean URI
- Konstanta
- Variabel Global
- Model
- View
- Controller
- Library
- CLI (command line interface)
- Core
Menggunakan Session
Seme Framework comes with builtin session manager which stored to $_SESSION
array with randomize string that define through configuration. Method setKey()
from Sene_controller allowed you to pass array of object or objects to save in session. And Method getKey()
allowed to get any stored value to session. Here is the example
class Home extends SENE_Controller{ public function __construct(){ parent::__construct(); } private funtion __init(){ $data = array(); $sess = $this->getKey(); if(!isset($sess->user_login)) $sess->user_login = 0; if(!isset($sess->user)) $sess->user = new stdClass(); if(isset($sess->user->id)) $sess->user_login = 1; $this->setKey($sess); $data['sess'] = $sess; return $data; } public function index(){ $data = $this->__init(); } public function set_logged_in(){ $sess = $this->getKey(); if(!isset($sess->user_login)) $sess->user_login = 1; if(!isset($sess->user)) $sess->user = new stdClass(); if(!isset($sess->user->id)) $sess->user->id = 1000; $this->setKey($sess); } public function set_logged_out(){ $sess = $this->getKey(); if(!isset($sess->user_login)) $sess->user_login = 0; if(!isset($sess->user)) $sess->user = new stdClass(); if(!isset($sess->user->id)) $sess->user->id = 1000; unset($sess->user->id); $this->setKey($sess); } }