Formatting output Plese Wait...
Session Management Class.
More...
|
Public Member Functions |
| zSession () |
| __construct () |
| started () |
| Is session started.
|
| start () |
| Starts the Session.
|
| getEncrypted ($key=null) |
| Get value of an encrypted session variable.
|
| setEncrypted ($key, $val) |
| Set value of an session variable in encrypted format.
|
| getPlain ($key=null) |
| get's value of a Plain(UnEncrypted) session data.
|
| setPlain ($key, $val) |
| Set's Session data as Plain Text(Un Encrypted) Stiores Session Data in Unencrypted Format so you need to invoke zSession::getPlain() to retrive its value.
|
| remove ($key=null) |
| Removes a Session Variable.
|
| keyExists ($key=null) |
| Checks wheather a Key exists with the name provided or not.
|
| commit () |
| Stores the session Data Immedietly.
|
| regenerateId ($delOldFlag=true) |
| Regenarates Session ID.
|
| cookieParams ($lifeTime=null, $path=null, $domain=null, $secure=null, $httpOnly=null) |
| get/set the session cookie parameters.
|
| Id ($id=null) |
| get/set the Current session's Id
|
| Name ($sessionName=null) |
| get/set the name of the current session
|
| rollBack ($savePointName=null) |
| Rolls back the session data to the previous stage or to a Specified save point.
|
| savePoint ($savePointName) |
| sets a savepoint
|
Data Fields |
| $bak = array() |
| $savePoint = array() |
Detailed Description
Session Management Class.
zSession Class can be used with its static methods e.g. zSession::methodName() like zSession::start() or zSession::started() etc.. zSession can also be used from its Instance in ROM. which can be found on $request->session through $request Global Variable. and as ROM engine is embeded into Controller you can also use $this->request->session to call a static/non-static method from the Instance. zSession Class holds several static and non-static methods static methods can be called without an instance where as you must use ROM engine to call a non-static method. You can also use PHP's $_SESSION with it however this is more structured way. setting and getting variables through $_SESSION ould work like zSession::setPlain() and zSession::getPlain(). It also Supports Magic Methods like getName(), setName('Foo') etc..
Definition at line 40 of file session_handler.php.
Constructor & Destructor Documentation
Reimplemented from zCore.
Definition at line 59 of file session_handler.php.
Referenced by zSession().
Show Source00059 {
00060 global $_SESSION;
00061 parent::__construct();
00062 if(!defined('DELETE_OLD_SESSION'))define('DELETE_OLD_SESSION', true);
00063 if(!defined('KEEP_OLD_SESSION'))define('KEEP_OLD_SESSION', false);
00064 $this->bak = $_SESSION;
00065 }
Top
Member Function Documentation
Is session started.
checks wheather the session has been started or not. Returns true if sesssion has been already started else returns false.
- Returns:
- bool
Definition at line 73 of file session_handler.php.
References zLogger::debug().
Referenced by commit(), cookieParams(), Id(), regenerateId(), and start().
Show Source00073 {
00074 if(isset($_SESSION)){
00075 zLogger::debug("zSession::start() returning true as session has been started", 'rom.session');
00076 return true;
00077 }else{
00078 zLogger::debug("zSession::start() returning false as session has not been started yet", 'rom.session');
00079 return false;
00080 }
00081 }
Top
Starts the Session.
Starts the Session if already not started. It doesn't start the Session if it already has been started so that session is started only once. By default Zigmoyd starts Session automatically at the begening. Hoe you can change this behavior (But not recomended) by changing the value of Z_SESSION_AUTO_START in etc/zig.ini.php of your Project.
- Warning:
- Remember in PHP the Session variable Name is PHPSESSID By default however Zigmoyd Changes it and Uses ZSESSID Instead. However you can change it if you want by changing the value of Z_SESSION_NAME in the INI file etc/zig.ini.php of your Project.
- Returns:
- void
Definition at line 93 of file session_handler.php.
References zLogger::debug(), and started().
Referenced by zCaptcha::captcha(), commit(), cookieParams(), getEncrypted(), getPlain(), Id(), regenerateId(), setEncrypted(), and setPlain().
Show Source00093 {
00094 if(!session_id() && !headers_sent() && !zSession::started()){
00095 session_name(Z_SESSION_NAME);
00096 zLogger::debug("Starting session", 'rom.session');
00097 session_start();
00098 }else{
00099 zLogger::debug("session already started", 'rom.session');
00100 }
00101 }
Top
zSession::getEncrypted( string $key = null
)
Get value of an encrypted session variable.
Zigmoyd is able to set/get session data in encrypted format using your current Encryption settings. So If you set a session data in Encrypted format using zSession::setEncrypted() You need to call zSession::getEncrypted() to retrive its value.
- Warning:
- If Set Session in Unencrypted format by invoking zSession::setPlain() and try to retrive it by zSession::getEncrypted() it will not give you correct data cause you are decrypting an unencrypted data.
- Parameters:
-
| $key | Name of Session variable |
- Returns:
- mixed
Definition at line 113 of file session_handler.php.
References zLogger::debug(), zCrypt::decrypt(), perror(), and start().
Show Source00113 {
00114 zLogger::debug("Getting value of Encrypted Key $key", 'rom.session');
00115 zSession::start();
00116 if(is_array($key)){
00117 perror('zSession::get() doesn\'t accept array');
00118 }
00119 if($key != null){
00120 if(isset($_SESSION[$key])){
00121 return zCrypt::decrypt($_SESSION[$key], true);
00122 }else{
00123 perror('<code>zigmoyd.session.get</code><br />Trying to get non existing session Variable `'.$key.'`');
00124 }
00125 }else{
00126 return zCrypt::decrypt($_SESSION, true);
00127 }
00128 return false;
00129 }
Top
zSession::setEncrypted( string $key, mixed $val )
zSession::getPlain( string $key = null
)
get's value of a Plain(UnEncrypted) session data.
returns value of a Session data which is set using zSession::setPlain() method or set as unEncrypted text through some other way e.g. $_SESSION etc..
- Parameters:
-
| $key | session variable Name |
- Returns:
- mixed
Definition at line 155 of file session_handler.php.
References zLogger::debug(), perror(), and start().
Show Source00155 {
00156 zLogger::debug("Getting value of Key $key", 'rom.session');
00157 zSession::start();
00158 if(is_array($key)){
00159 perror('zSession::getPlain() doesn\'t accept array');
00160 }
00161 if($key != null){
00162 if(isset($_SESSION[$key])){
00163 return $_SESSION[$key];
00164 }else{
00165 perror('<code>zigmoyd.session.get</code><br />Trying to get non existing session Variable `'.$key.'`');
00166 }
00167 }else{
00168 return $_SESSION;
00169 }
00170 return false;
00171 }
Top
zSession::setPlain( string $key, mixed $val )
zSession::remove( string $key = null
)
Removes a Session Variable.
removes a session Variable doesn't matter if its encrypted or not.
- Parameters:
-
| $key | Session variable name |
- Returns:
- boolean
Definition at line 193 of file session_handler.php.
References zLogger::debug(), keyExists(), and perror().
Show Source00193 {
00194 zLogger::debug("removing Key $key", 'rom.session');
00195 if($key == null || !is_string($key)){
00196 perror("<code>zSession::remove()</code><br />You must provide which key to delete and that argumnt must be a string to zSession::remove() e.g. it accepts 1 argumnt");return false;
00197 return false;
00198 }
00199 if(!zSession::keyExists($key)){
00200 perror("<code>zSession::remove()</code><br />zSession::remove() failed to remove key $key from session as it doesn't exist");return false;
00201 return false;
00202 }else{
00203 unset($_SESSION[$key]);
00204 return true;
00205 }
00206 }
Top
zSession::keyExists( string $key = null
)
Checks wheather a Key exists with the name provided or not.
Checks wheather or not a Session Variable exists with the provided key Name. Returns boolean value. e.g. true if it exists false otherwise
- Parameters:
-
| $key | Session Variable Name |
- Returns:
- boolean
Definition at line 214 of file session_handler.php.
References perror().
Referenced by remove().
Show Source00214 {
00215 if($key == null || !is_string($key)){
00216 perror("<code>zSession::keyExists()</code><br />You must provide which key to Check and that argumnt must be a string to zSession::keyExists() e.g. it accepts 1 argumnt");
00217 return false;
00218 }
00219 return isset($_SESSION[$key]);
00220 }
Top
zSession::regenerateId( string $delOldFlag = true
)
Regenarates Session ID.
replace the current session id with a new one, and keep the current session information
- Parameters:
-
| $delOldSession | boolean Deleta Old session Data or not ? boolean value |
- Returns:
- boolean
Definition at line 238 of file session_handler.php.
References zLogger::debug(), start(), and started().
Top
zSession::cookieParams( int $lifeTime = null
, string $path = null
, string $domain = null
, boolean $secure = null
, boolean $httpOnly = null
)
get/set the session cookie parameters.
Works like session_set_cookie_params() standared PHP function.
- Parameters:
-
| $lifeTime | |
| $path | |
| $domain | |
| $secure | |
| $httpOnly | |
- Returns:
- mixed
Definition at line 254 of file session_handler.php.
References start(), and started().
Show Source00254 {
00255 if(!zSession::started())zSession::start();
00256 if(is_null($lifeTime) && is_null($path) && is_null($domain) && is_null($secure) && is_null($httpOnly)){
00257 return session_get_cookie_params();
00258 }else{
00259 $currentParams = session_get_cookie_params();
00260 if(is_null($lifeTime))$lifeTime = $currentParams['lifetime'];
00261 if(is_null($path))$path = $currentParams['path'];
00262 if(is_null($domain))$domain = $currentParams['domain'];
00263 if(is_null($secure))$secure = $currentParams['secure'];
00264 if(is_null($httpOnly))$httpOnly = $currentParams['httponly'];
00265 session_set_cookie_params($lifeTime, $path, $domain, $secure, $httpOnly);
00266 }
00267 }
Top
zSession::Id( string $id = null
)
zSession::Name( string $sessionName = null
)
get/set the name of the current session
- Parameters:
-
- Returns:
- mixed
Definition at line 290 of file session_handler.php.
References zLogger::debug().
Show Source00290 {
00291 if(!is_null($sessionName)){
00292 $sesName = (strlen(session_name($sessionName)) >= 1);
00293 }else{
00294 $sesName = session_name();
00295 }
00296 zLogger::debug("Returning session Name $sesName", 'rom.session');
00297 return $sesName;
00298 }
Top
zSession::rollBack( string $savePointName = null
)
Rolls back the session data to the previous stage or to a Specified save point.
- Warning:
- non-static method. Must be called from an Instance.
- Parameters:
-
| $savePointName | SavePoint Name to which you want to restore |
- Returns:
- void
Definition at line 306 of file session_handler.php.
References $val, savePoint(), and setPlain().
Top
zSession::savePoint( string $savePointName )
sets a savepoint
- Warning:
- non-static method. Must be called from an Instance.
- Parameters:
-
| $savePointName | Savepoint Name where to backup the Current Session Data |
Definition at line 323 of file session_handler.php.
Referenced by rollBack().
Show Source00323 {
00324 $this->savePoint[$savePointName] = $_SESSION;
00325 }
Top
Field Documentation
zSession::$savePoint = array()
The documentation for this class was generated from the following file: