You are here: Re: find a cookie by part of it's name « PHP Programming Language « IT news, forums, messages
Re: find a cookie by part of it's name

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)

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация