|
Posted by Kim Andrι Akerψ on 05/09/06 19:12
Ron Croonenberg wrote:
> Hi all,
>
> cookies are stored in an array called $HTTP_COOKIE_VARS right ?
>
> Is it possible to find a cookie if you know part of it's name ?
>
> For example the cookiename is firstname and I want to check all
> cookies that start with "first" in there name.
>
> I tried to work wih string and substrings, but that didn't seem
> to work ?
First of all, as others have said, use $_COOKIE instead.
Second, $_COOKIE is an array, so you can use the array functions to
find the cookie.
And since you're looking for the cookie *name*, array_search() and
array_keys() would be useful in this case. Like this:
$cookiename = array_search("firstname",array_keys($_COOKIE));
If the search turns up empty, then $cookiename = false, otherwise,
$cookiename will contain the name of the cookie. The value for the
cookie is then easily retrieved by $_COOKIE[$cookiename].
--
Kim AndrΓ© AkerΓΈ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
[Back to original message]
|