Forum PHP 2017

$_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 4 notes

up
59
k dot andris at gmail dot com
2 years ago
beware, dots (.) in cookie names are replaces by underscores (_)
up
31
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
-1
Anonymous
4 days ago
spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam ?spam spam spam ?spam spam spam ?spam spam spam ?spam spam spam !
up
-1
Anonymous
4 days ago
spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam ?spam spam spam ?spam spam spam ?spam spam spam ?spam spam spam !
To Top