Public Member Functions | |
setStore ($store) | |
getStore () | |
getDomain () | |
getPath () | |
getLifetime () | |
setLifetime ($lifetime) | |
getHttponly () | |
isSecure () | |
set ($name, $value, $period=null, $path=null, $domain=null, $secure=null, $httponly=null) | |
get ($name=null) | |
delete ($name, $path=null, $domain=null, $secure=null, $httponly=null) | |
Public Attributes | |
const | XML_PATH_COOKIE_DOMAIN = 'web/cookie/cookie_domain' |
const | XML_PATH_COOKIE_PATH = 'web/cookie/cookie_path' |
const | XML_PATH_COOKIE_LIFETIME = 'web/cookie/cookie_lifetime' |
const | XML_PATH_COOKIE_HTTPONLY = 'web/cookie/cookie_httponly' |
Protected Member Functions | |
_getRequest () | |
_getResponse () | |
Protected Attributes | |
$_lifetime | |
$_store |
Definition at line 35 of file Cookie.php.
_getRequest | ( | ) | [protected] |
Retrieve Request object
Definition at line 81 of file Cookie.php.
00082 { 00083 return Mage::app()->getRequest(); 00084 }
_getResponse | ( | ) | [protected] |
Retrieve Response object
Definition at line 91 of file Cookie.php.
00092 { 00093 return Mage::app()->getResponse(); 00094 }
delete | ( | $ | name, | |
$ | path = null , |
|||
$ | domain = null , |
|||
$ | secure = null , |
|||
$ | httponly = null | |||
) |
Delete cookie
string | $name | |
string | $path | |
string | $domain | |
int|bool | $secure | |
int|bool | $httponly |
Check headers sent
Definition at line 254 of file Cookie.php.
00255 { 00256 /** 00257 * Check headers sent 00258 */ 00259 if (!$this->_getResponse()->canSendHeaders(false)) { 00260 return $this; 00261 } 00262 00263 if (is_null($path)) { 00264 $path = $this->getPath(); 00265 } 00266 if (is_null($domain)) { 00267 $domain = $this->getDomain(); 00268 } 00269 if (is_null($secure)) { 00270 $secure = $this->isSecure(); 00271 } 00272 if (is_null($httponly)) { 00273 $httponly = $this->getHttponly(); 00274 } 00275 00276 setcookie($name, null, null, $path, $domain, $secure, $httponly); 00277 return $this; 00278 }
get | ( | $ | name = null |
) |
Retrieve cookie or false if not exists
string | $neme The cookie name |
Definition at line 239 of file Cookie.php.
00240 { 00241 return $this->_getRequest()->getCookie($name, false); 00242 }
getDomain | ( | ) |
Retrieve Domain for cookie
Definition at line 101 of file Cookie.php.
00102 { 00103 $domain = Mage::getStoreConfig(self::XML_PATH_COOKIE_DOMAIN, $this->getStore()); 00104 if (empty($domain)) { 00105 $domain = $this->_getRequest()->getHttpHost(); 00106 } 00107 return $domain; 00108 }
getHttponly | ( | ) |
Retrieve use HTTP only flag
Definition at line 160 of file Cookie.php.
00161 { 00162 $httponly = Mage::getStoreConfig(self::XML_PATH_COOKIE_HTTPONLY, $this->getStore()); 00163 if (is_null($httponly)) { 00164 return null; 00165 } 00166 return (bool)$httponly; 00167 }
getLifetime | ( | ) |
Retrieve cookie lifetime
Definition at line 129 of file Cookie.php.
00130 { 00131 if (null !== $this->_lifetime) { 00132 $lifetime = $this->_lifetime; 00133 } 00134 else { 00135 $lifetime = Mage::getStoreConfig(self::XML_PATH_COOKIE_LIFETIME, $this->getStore()); 00136 } 00137 if (!is_numeric($lifetime)) { 00138 $lifetime = 3600; 00139 } 00140 return $lifetime; 00141 }
getPath | ( | ) |
Retrieve Path for cookie
Definition at line 115 of file Cookie.php.
00116 { 00117 $path = Mage::getStoreConfig(self::XML_PATH_COOKIE_PATH, $this->getStore()); 00118 if (empty($path)) { 00119 $path = $this->_getRequest()->getBasePath(); 00120 } 00121 return $path; 00122 }
getStore | ( | ) |
Retrieve Store object
Definition at line 68 of file Cookie.php.
00069 { 00070 if (is_null($this->_store)) { 00071 $this->_store = Mage::app()->getStore(); 00072 } 00073 return $this->_store; 00074 }
isSecure | ( | ) |
Is https secure request Use secure on adminhtml only
Definition at line 175 of file Cookie.php.
00176 { 00177 if ($this->getStore()->isAdmin()) { 00178 return $this->_getRequest()->isSecure(); 00179 } 00180 return false; 00181 }
set | ( | $ | name, | |
$ | value, | |||
$ | period = null , |
|||
$ | path = null , |
|||
$ | domain = null , |
|||
$ | secure = null , |
|||
$ | httponly = null | |||
) |
Set cookie
string | $name The cookie name | |
string | $value The cookie value | |
int | $period Lifetime period | |
string | $path | |
string | $domain | |
int|bool | $secure |
Check headers sent
Definition at line 194 of file Cookie.php.
00195 { 00196 /** 00197 * Check headers sent 00198 */ 00199 if (!$this->_getResponse()->canSendHeaders(false)) { 00200 return $this; 00201 } 00202 00203 if ($period === true) { 00204 $period = 3600 * 24 * 365; 00205 } elseif (is_null($period)) { 00206 $period = $this->getLifetime(); 00207 } 00208 00209 if ($period == 0) { 00210 $expire = 0; 00211 } 00212 else { 00213 $expire = time() + $period; 00214 } 00215 if (is_null($path)) { 00216 $path = $this->getPath(); 00217 } 00218 if (is_null($domain)) { 00219 $domain = $this->getDomain(); 00220 } 00221 if (is_null($secure)) { 00222 $secure = $this->isSecure(); 00223 } 00224 if (is_null($httponly)) { 00225 $httponly = $this->getHttponly(); 00226 } 00227 00228 setcookie($name, $value, $expire, $path, $domain, $secure, $httponly); 00229 00230 return $this; 00231 }
setLifetime | ( | $ | lifetime | ) |
Set cookie lifetime
int | $lifetime |
Definition at line 149 of file Cookie.php.
setStore | ( | $ | store | ) |
Set Store object
mixed | $store |
Definition at line 57 of file Cookie.php.
00058 { 00059 $this->_store = Mage::app()->getStore($store); 00060 return $this; 00061 }
$_lifetime [protected] |
Definition at line 42 of file Cookie.php.
$_store [protected] |
Definition at line 49 of file Cookie.php.
const XML_PATH_COOKIE_DOMAIN = 'web/cookie/cookie_domain' |
Definition at line 37 of file Cookie.php.
const XML_PATH_COOKIE_HTTPONLY = 'web/cookie/cookie_httponly' |
Definition at line 40 of file Cookie.php.
const XML_PATH_COOKIE_LIFETIME = 'web/cookie/cookie_lifetime' |
Definition at line 39 of file Cookie.php.
const XML_PATH_COOKIE_PATH = 'web/cookie/cookie_path' |
Definition at line 38 of file Cookie.php.