$_COOKIE -- $HTTP_COOKIE_VARS [نامطلوب]کوکی‌های HTTP


یک array شرکت‌پذیر از متغیرها که از طریق کوکی HTTP به اسکریپت فعلی ارسال شده است.

$HTTP_COOKIE_VARS شامل همان اطلاعات اولیه است اما یک superglobal نیست. (توجه کنید $HTTP_COOKIE_VARS و $_COOKIE متغیرهای متفاوتی هستند و PHP آنها را همانگونه پردازش می‌نماید)


Version Description
4.1.0 معرفی $_COOKIE موجب نامطلوب شدن $HTTP_COOKIE_VARS شد.


Example #1 نمونه $_COOKIE

echo 'Hello ' htmlspecialchars($_COOKIE["name"]) . '!';

با فرض تعیین شدن پیشین "name" در کوکی

The above example will output something similar to:

Hello Hannes!



This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. There is no need to do global $variable; to access it within functions or methods.

add a note add a note

User Contributed Notes 3 notes

kiril (at) atern (dot) us
1 year ago
To clarify the previously posted note:

Dots (.) and spaces ( ) in cookie names are being replaced with underscores (_).
k dot andris at gmail dot com
2 years ago
beware, dots (.) in cookie names are replaces by underscores (_)
alexander-schranz at NO_SPAM dot hotmail dot com
1 month ago
Cookies with the same name the first cookie is used. Clients will send cookies with longer path before cookies with shorter path. This comes from RFC 6265 which says "Cookies with longer paths are listed before cookies with shorter paths.". So you get the best matching cookie for your current request.
To Top