クッキー

クッキー – HTTP_Request でクッキーを利用する

HTTP リクエストへのクッキーの追加方法

リクエストにクッキーを追加する

この例では、version というクッキーが HTTP リクエストに追加されます。このクッキーの値は、 HTTP_Request インスタンスが動作している PHP インタプリタのバージョン文字列です。

<?php
require_once "HTTP/Request.php";

$req =& new HTTP_Request("http://example.com/");
$req->addCookie("version"phpversion());

$response $req->sendRequest();

if (
PEAR::isError($response)) {
    echo 
$response->getMessage();
} else {
    echo 
$req->getResponseBody();
}
?>

HTTP レスポンスからクッキーを読み込む

HTTP レスポンスのクッキーを読み込みは、以下の例で示されます。

<?php
require_once "HTTP/Request.php";

$req =& new HTTP_Request("http://example.com/");

$response $req->sendRequest();

if (
PEAR::isError($response)) {
    echo 
$response->getMessage();
} else {
    
print_r($req->getResponseCookies());
}
?>
保護された Web サイトのための認証 (Previous) HTTP 経由でファイルをアップロードする (Next)
Last updated: Fri, 25 May 2012 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.