Once a Zend_Http_Cookie object is instantiated, it provides
several getter methods to get the different properties of the HTTP
cookie:
getName(): Get the name of the cookiegetValue(): Get the real, decoded value of the cookiegetDomain(): Get the cookie's domaingetPath(): Get the cookie's path, which defaults to '/'getExpiryTime(): Get the cookie's expiration time, as UNIX time stamp. If the cookie has no expiration time set, will returnNULL.
Additionally, several boolean tester methods are provided:
isSecure(): Check whether the cookie is set to be sent over secure connections only. Generally speaking, ifTRUEthe cookie should only be sent over HTTPS.isExpired(int $time = null): Check whether the cookie is expired or not. If the cookie has no expiration time, will always returnTRUE. If $time is provided, it will override the current time stamp as the time to check the cookie against.isSessionCookie(): Check whether the cookie is a "session cookie" - that is a cookie with no expiration time, which is meant to expire when the session ends.
Example 486. Using getter methods with Zend_Http_Cookie
<?php
// First, create the cookie
$cookie =
Zend_Http_Cookie::fromString('foo=two+words; ' +
'domain=.example.com; ' +
'path=/somedir; ' +
'secure; ' +
'expires=Wednesday, 28-Feb-05 20:41:22 UTC');
echo $cookie->getName(); // Will echo 'foo'
echo $cookie->getValue(); // will echo 'two words'
echo $cookie->getDomain(); // Will echo '.example.com'
echo $cookie->getPath(); // Will echo '/'
echo date('Y-m-d', $cookie->getExpiryTime());
// Will echo '2005-02-28'
echo ($cookie->isExpired() ? 'Yes' : 'No');
// Will echo 'Yes'
echo ($cookie->isExpired(strtotime('2005-01-01') ? 'Yes' : 'No');
// Will echo 'No'
echo ($cookie->isSessionCookie() ? 'Yes' : 'No');
// Will echo 'No'




