From 8c0cc31021515bdc29a6c6ebc44e903acdb0430f Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 5 Mar 2006 04:00:52 +0000 Subject: Added name-based cookie retrieval. --- framework/Web/THttpRequest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'framework/Web/THttpRequest.php') diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php index 293c73f1..d3a8480a 100644 --- a/framework/Web/THttpRequest.php +++ b/framework/Web/THttpRequest.php @@ -681,6 +681,12 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar * THttpCookieCollection class. * * THttpCookieCollection implements a collection class to store cookies. + * Besides using all functionalities from {@link TList}, you can also + * retrieve a cookie by its name using either {@link findCookieByName} or + * simply: + * + * $cookie=$collection[$cookieName]; + * * * @author Qiang Xue * @version $Revision: $ $Date: $ @@ -738,6 +744,18 @@ class THttpCookieCollection extends TList return $item; } + /** + * @param integer|string index of the cookie in the collection or the cookie's name + * @return THttpCookie the cookie found + */ + public function itemAt($index) + { + if(is_integer($index)) + return parent::itemAt($index); + else + return $this->findCookieByName($index); + } + /** * Finds the cookie with the specified name. * @param string the name of the cookie to be looked for -- cgit v1.2.3