Loading Please wait...

zCookie Class Reference
[Cookie Management.]

Cookie Management Class. More...

Inheritance diagram for zCookie:

Inheritance graph
[legend]
Collaboration diagram for zCookie:

Collaboration graph
[legend]

Public Member Functions

 zCookie ()
 __construct ()
 getEncrypted ($key=null)
 Get value of an encrypted cookie variable.
 setEncrypted ($key, $val, $expire=null, $path='', $domain=null, $secure=null, $httpOnly=null)
 Set value of a cookie variable in encrypted format.
 getPlain ($key=null)
 get's value of a Plain(UnEncrypted) cookie data.
 setPlain ($key, $val, $expire=0, $path='', $domain=null, $secure=null, $httpOnly=null)
 Puts Cookie data in Plain text format(e.g.
 setRaw ($key, $val, $expire=0, $path=null, $domain=null, $secure=null, $httpOnly=null)
 Send a Raw Cookie.
 remove ($key=null)
 Removes a Key from Cookie.
 keyExists ($key=null)
 Checks wheather a Key exists with the name provided or not.

Detailed Description

Cookie Management Class.

zCookie Class can be used with its static methods e.g. zCookie::methodName() like zCookie::getPlain() or zCookie::setPlain() etc.. zCookie can also be used from its Instance in ROM. which can be found on $request->cookie through $request Global Variable. and as ROM engine is embeded into Controller you can also use $this->request->cookie to call a static/non-static method from the Instance. zCookie 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 $_COOKIE with it however this is more structured way. setting and getting variables through $_COOKIE would work like zCookie::setPlain() and zCookie::getPlain(). It also Supports Magic Methods like getName(), setName('Foo') etc..

Definition at line 40 of file cookie_handler.php.


Constructor & Destructor Documentation

zCookie::__construct (  ) 

Reimplemented from zCore.

Definition at line 44 of file cookie_handler.php.

References zDef::set().

Referenced by zCookie().

00044                         {
00045     zDef::set('Z_COOKIE_EXPIRE', Z_COOKIE_EXPIRE);
00046     zDef::set('Z_COOKIE_SECURE', Z_COOKIE_SECURE);
00047     zDef::set('Z_COOKIE_HTTPONLY', Z_COOKIE_HTTPONLY);
00048   }

Here is the call graph for this function:


Member Function Documentation

zCookie::zCookie (  ) 

Definition at line 41 of file cookie_handler.php.

References __construct().

00041                     {
00042     $this->__construct();
00043   }

Here is the call graph for this function:

zCookie::getEncrypted ( key = null  ) 

Get value of an encrypted cookie variable.

Zigmoyd is able to set/get cookie data in encrypted format using your current Encryption settings. So If you set a cookie data in Encrypted format using zCookie::setEncrypted() You need to call zCookie::getEncrypted() to retrive its value.

Warning:
If You Set Cookie in Unencrypted format by invoking zCookie::setPlain() and try to retrive it by zCookie::getEncrypted() it will not give you correct data cause you are decrypting an unencrypted data.
Parameters:
$key string Name of Cookie variable
Returns:
mixed

Definition at line 60 of file cookie_handler.php.

References zLogger::debug(), zCrypt::decrypt(), and perror().

00060                                   {
00061     if(is_array($key)){
00062       perror('zCookie::getEncrypted() doesn\'t accept array');
00063       exit;
00064     }
00065     if($key != null){
00066       zLogger::debug("Getting Value of Encrypted Key $key", 'rom.cookie');
00067       if(isset($_COOKIE[$key])){
00068         return zCrypt::decrypt($_COOKIE[$key], true);
00069       }else{
00070         perror('<code>zigmoyd.Cookie.get</code><br />Trying to get non existing Cookie Variable `'.$key.'`');
00071       }
00072     }else{
00073       return zCrypt::decrypt($_COOKIE, true);
00074     }
00075     return false;
00076   }

Here is the call graph for this function:

zCookie::setEncrypted ( key,
val,
expire = null,
path = '',
domain = null,
secure = null,
httpOnly = null 
)

Set value of a cookie variable in encrypted format.

Zigmoyd is able to set/get cookie data in encrypted format using your current Encryption settings. So you can set a cookie data in Encrypted format using zCookie::setEncrypted() You need to call zCookie::getEncrypted() to retrive its value.

Warning:
If Set Cookie in encrypted format by invoking zCookie::setEncrypted() and try to retrive it by zCookie::getPlain() it will not give you correct data cause you are not decrypting an encrypted data.
Parameters:
$key string
$val mixed
$expire int
$path string
$domain string
$secure boolen
$httpOnly boolean
Returns:
boolean

Definition at line 94 of file cookie_handler.php.

References $val, zLogger::debug(), zCrypt::encrypt(), and zDef::get().

00094                                                                                                        {
00095     if(is_null($expire))$expire = zDef::get('Z_COOKIE_EXPIRE');
00096     if(is_null($secure))$expire = zDef::get('Z_COOKIE_SECURE');
00097     if(is_null($httpOnly))$expire = zDef::get('Z_COOKIE_HTTPONLY');
00098     zLogger::debug("Setting Value of Encrypted Key:$key Value:$val Expire: $expire, Path: $path Domain: $domain Secure: $secure HTTPOnly: $httpOnly", 'rom.cookie');
00099     return setcookie($key, zCrypt::encrypt($val, true), (int)$expire, (string)$path, $domain, $secure);
00100   }

Here is the call graph for this function:

zCookie::getPlain ( key = null  ) 

get's value of a Plain(UnEncrypted) cookie data.

returns value of a Cookie data which is set using zCookie::setPlain() method or set as unEncrypted text through some other way e.g. $_COOKIE etc..

Parameters:
$key string cookie variable Name
Returns:
mixed

Definition at line 108 of file cookie_handler.php.

References zLogger::debug(), and perror().

00108                               {
00109     if(is_array($key)){
00110       perror('zCookie::getPlain() doesn\'t accept array');
00111     }
00112     if($key != null){
00113       zLogger::debug("Getting Value of Key $key", 'rom.cookie');
00114       if(isset($_COOKIE[$key])){
00115         return $_COOKIE[$key];
00116       }else{
00117         perror('<code>zigmoyd.Cookie.get</code><br />Trying to get non existing Cookie Variable `'.$key.'`');
00118       }
00119     }else{
00120       return $_COOKIE;
00121     }
00122     return false;
00123   }

Here is the call graph for this function:

zCookie::setPlain ( key,
val,
expire = 0,
path = '',
domain = null,
secure = null,
httpOnly = null 
)

Puts Cookie data in Plain text format(e.g.

Un encrypted). Stiores Cookie Data in Unencrypted Format so you need to invoke zCookie::getPlain() to retrive its value

Parameters:
$key string
$val mixed
$expire int
$path string
$domain string
$secure boolen
$httpOnly boolean
Returns:
boolean

Definition at line 137 of file cookie_handler.php.

References $val, zLogger::debug(), and zDef::get().

00137                                                                                                 {
00138     if(is_null($expire))$expire = zDef::get('Z_COOKIE_EXPIRE');
00139     if(is_null($secure))$expire = zDef::get('Z_COOKIE_SECURE');
00140     if(is_null($httpOnly))$expire = zDef::get('Z_COOKIE_HTTPONLY');
00141     zLogger::debug("Setting Value of Key:$key Value:$val Expire: $expire, Path: $path Domain: $domain Secure: $secure HTTPOnly: $httpOnly", 'rom.cookie');
00142     return setcookie($key, $val, (int)$expire, (string)$path, $domain, $secure);
00143   }

Here is the call graph for this function:

zCookie::setRaw ( key,
val,
expire = 0,
path = null,
domain = null,
secure = null,
httpOnly = null 
)

Send a Raw Cookie.

Send a cookie without urlencoding the cookie value.

Parameters:
$key string
$val mixed
$expire int
$path string
$domain string
$secure boolen
$httpOnly boolean
Returns:
boolean

Definition at line 157 of file cookie_handler.php.

References $val, zLogger::debug(), and zDef::get().

00157                                                                                                 {
00158     if(is_null($expire))$expire = zDef::get('Z_COOKIE_EXPIRE');
00159     if(is_null($secure))$expire = zDef::get('Z_COOKIE_SECURE');
00160     if(is_null($httpOnly))$expire = zDef::get('Z_COOKIE_HTTPONLY');
00161     zLogger::debug("Setting Value of Raw Key:$key Value:$val Expire: $expire, Path: $path Domain: $domain Secure: $secure HTTPOnly: $httpOnly", 'rom.cookie');
00162     return setrawcookie($key, $val, $expire, $path, $domain, $secure, $httpOnly);
00163   }

Here is the call graph for this function:

zCookie::remove ( key = null  ) 

Removes a Key from Cookie.

Parameters:
$key string
Returns:
boolean

Definition at line 170 of file cookie_handler.php.

References zLogger::debug(), keyExists(), and perror().

00170                             {
00171     if($key == null || !is_string($key)){
00172       perror("<code>zCookie::remove()</code><br />You must provide which key to delete and that argumnt must be a string to zCookie::remove() e.g. it accepts 1 argumnt");return false;
00173       return false;
00174     }
00175     if(!zCookie::keyExists($key)){
00176       perror("<code>zCookie::remove()</code><br />zCookie::remove() failed to remove key $key from Cookie as it doesn't exist");return false;
00177       return false;
00178     }else{
00179       zLogger::debug("Removing Key $key", 'rom.cookie');
00180       setcookie($key, "", time()-1);
00181       unset($_COOKIE[$key]);
00182       return true;
00183     }
00184   }

Here is the call graph for this function:

zCookie::keyExists ( key = null  ) 

Checks wheather a Key exists with the name provided or not.

Parameters:
$key string
Returns:
boolean

Definition at line 191 of file cookie_handler.php.

References zLogger::debug(), and perror().

Referenced by remove().

00191                                {
00192     if($key == null || !is_string($key)){
00193       perror("<code>zCookie::keyExists()</code><br />You must provide which key to delete and that argumnt must be a string to zCookie::keyExists() e.g. it accepts 1 argumnt");return false;
00194       return false;
00195     }
00196     if(!isset($_COOKIE[$key])){
00197       zLogger::debug("zCookie::keyExists() says Key $key Doesn't exist", 'rom.cookie');
00198       return false;
00199     }else{
00200       zLogger::debug("zCookie::keyExists() says Key $key exists", 'rom.cookie');
00201       return true;
00202     }
00203   }

Here is the call graph for this function:


The documentation for this class was generated from the following file:

Generated on Mon Oct 27 23:53:23 2008 for zigmoyd.kdevelop by doxygen 1.5.6