- Seme Framework
- version 4.0.3
- Requirements
- Download & Install
- Configuration
- Tutorials
- URI Routing
- Constants
- Global Variables
- Model
- View
- Controller
- cdn_url
- config
- constructor
- getAdditional
- getAdditionalBefore
- getAdditionalAfter
- getAuthor
- getCanonical
- getContentLanguage
- getDescription
- getIcon
- getJsContent
- getJsFooter
- getJsReady
- getKey
- getKeyword
- getLang
- getRobots
- getShortcutIcon
- getThemeElement
- getTitle
- input
- lib
- load
- loadCss
- loadLayout
- putThemeContent
- putJsContent
- putJsFooter
- putJsReady
- putThemeContent
- render
- resetThemeContent
- session
- setAuthor
- setCanonical
- setContentLanguage
- setDescription
- setIcon
- setKey
- setKeyword
- setLang
- setShortcutIcon
- setTheme
- setTitle
- Library
- CLI (command line interface)
- Core
- Issue
- Deployment
Using Session
Seme Framework comes with builtin session manager which stored to $_SESSION
array with randomize string that define through configuration.
Method setKey()
Method setKey()
from Sene_controller allowed you to pass array of object or objects to save in session.
Method getKey()
Method getKey()
allowed to get any stored value to session.
Example
Here is the example usage for getKey()
method and setKey()
method.
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);
}
}