-
Notifications
You must be signed in to change notification settings - Fork 10
Session
Stefano Azzolini edited this page Aug 27, 2014
·
1 revision
The Session module allow you to make hashes of variables.
Start the session handler with the Session::start
method.
Session::start();
You can pass a custom SID string as parameter.
Session::start("AWESOME_APP_SID");
All saved data and the session can be deleted with the Session::clear
method.
Session::clear();
You can retrieve a value from session stash via the Session::get
method. An optional second parameter can be passed for a default value if the requested one is missing.
$mydata = Session::get('mydata',"some default data");
You can set a value into session stash via the Session::set
method.
$mydata = Session::get('my_options',[
'a' => 1,
'b' => 2,
]);
$mydata['a']++;
print_r( Session::set('my_options',$mydata) );
First run
Array
(
[a] => 1
[b] => 2
)
Second run
Array
(
[a] => 2
[b] => 2
)
You can check if a variable is in session stash with the Session::exists
method.
if(!Session::exists('user')) Redirect::to('/login');
Core is maintained by using the Semantic Versioning Specification (SemVer).
Copyright 2014-2016 Caffeina srl under the MIT license.
http://caffeina.com