Mid-Atlantic Developer Conference - Call for Speakers

$_COOKIE

$HTTP_COOKIE_VARS [نامطلوب]

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

Description

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

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

Changelog

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

Examples

Example #1 نمونه $_COOKIE

<?php
echo 'Hello ' htmlspecialchars($_COOKIE["name"]) . '!';
?>

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

The above example will output something similar to:

Hello Hannes!

Notes

Note:

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

up
66
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 (_).
up
72
k dot andris at gmail dot com
2 years ago
beware, dots (.) in cookie names are replaces by underscores (_)
up
0
alexander-schranz at NO_SPAM dot hotmail dot com
7 days 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