The HttpRequest
PHP 手册

HttpRequest::addCookies

(PECL pecl_http >= 0.10.0)

HttpRequest::addCookiesAdd cookies

说明

public bool HttpRequest::addCookies ( array $cookies )

Add custom cookies.

Note: The request option encodecookies controls whether the cookie values should be urlencode()d.

Note: Affects any request method.

参数

cookies

an associative array containing any cookie name/value pairs to add

返回值

如果成功则返回 TRUE,失败则返回 FALSE

范例

Example #1 A HttpRequest::addCookies() example

<?php
$r 
= new HttpRequest;
$r->addCookies(
    array(
        
"cookie_name" => "cookie value",
    )
);
?>

参见


The HttpRequest
PHP 手册