HttpRequest.Cookies プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > HttpRequest.Cookies プロパティの意味・解説 

HttpRequest.Cookies プロパティ

クライアントから送信された cookies のコレクションを取得します。

名前空間: System.Web
アセンブリ: System.Web (system.web.dll 内)
構文構文

Dim instance As HttpRequest
Dim value As HttpCookieCollection

value = instance.Cookies
public HttpCookieCollection Cookies { get;
 }
public:
property HttpCookieCollection^ Cookies {
    HttpCookieCollection^ get ();
}
/** @property */
public HttpCookieCollection get_Cookies ()
public function get Cookies
 () : HttpCookieCollection

プロパティ値
クライアントの Cookie 変数を表す HttpCookieCollection オブジェクト。

解説解説
使用例使用例

クライアントから送信されたすべての Cookie をループ処理して、名前、有効期限、セキュリティ パラメータ、および各 Cookie の値を HTTP 出力に送信するコード例を次に示します。

Dim loop1, loop2 As Integer
Dim arr1(), arr2() As String
Dim MyCookieColl As HttpCookieCollection 
Dim MyCookie As HttpCookie

MyCookieColl = Request.Cookies
' Capture all cookie names into a string array.
arr1 = MyCookieColl.AllKeys
' Grab individual cookie objects by cookie name     
for loop1 = 0 To arr1.GetUpperBound(0)
   MyCookie = MyCookieColl(arr1(loop1))
   Response.Write("Cookie: " & MyCookie.Name &
 "<br>")
   Response.Write("Expires: " & MyCookie.Expires
 & "<br>")
   Response.Write ("Secure:" & MyCookie.Secure
 & "<br>")

   ' Grab all values for single cookie into an object array.
   arr2 = MyCookie.Values.AllKeys
   ' Loop through cookie value collection and print all values.
   for loop2 = 0 To arr2.GetUpperBound(0)
      Response.Write("Value " & CStr(loop2) +
 ": " & Server.HtmlEncode(arr2(loop2)) &
 "<br>")
   Next loop2
Next loop1
  
int loop1, loop2;
HttpCookieCollection MyCookieColl;
HttpCookie MyCookie;
 
MyCookieColl = Request.Cookies;

// Capture all cookie names into a string array.
String[] arr1 = MyCookieColl.AllKeys;

// Grab individual cookie objects by cookie name.
for (loop1 = 0; loop1 < arr1.Length; loop1++) 
{
   MyCookie = MyCookieColl[arr1[loop1]];
   Response.Write("Cookie: " + MyCookie.Name + "<br>");
   Response.Write("Expires: " + MyCookie.Expires + "<br>");
   Response.Write ("Secure:" + MyCookie.Secure + "<br>");
 
   //Grab all values for single cookie into an object array.
   String[] arr2 = MyCookie.Values.AllKeys;

   //Loop through cookie Value collection and print all values.
   for (loop2 = 0; loop2 < arr2.Length; loop2++) 
   {
      Response.Write("Value" + loop2 + ": " + Server.HtmlEncode(arr2[loop2])
 + "<br>");
   }
}
   
int loop1, loop2;
HttpCookieCollection myCookieColl;
HttpCookie myCookie;

myCookieColl = get_Request().get_Cookies();

// Capture all cookie names into a string array.
String arr1[] = myCookieColl.get_AllKeys();

// Grab individual cookie objects by cookie name.
for (loop1 = 0; loop1 < arr1.length; loop1++) {
    myCookie = myCookieColl.get_Item(arr1[loop1]);
    get_Response().Write(("Cookie: " + myCookie.get_Name() + "<br>"));
    get_Response().Write(("Expires: " + myCookie.get_Expires()
        + "<br>"));
    get_Response().Write(("Secure:" + myCookie.get_Secure() + "<br>"));

    //Grab all values for single cookie into an object array.
    String arr2[] = myCookie.get_Values().get_AllKeys();

    //Loop through cookie Value collection and print all values.
    for (loop2 = 0; loop2 < arr2.length; loop2++) {
        get_Response().Write(("Value" + loop2 + ": "
            + get_Server().HtmlEncode(arr2[loop2]) + "<br>"));
    }
}
var arr1, arr2 : String[]
var myCookieColl : HttpCookieCollection 
var myCookie : HttpCookie

myCookieColl = Request.Cookies
// Capture all cookie names into a string array.
arr1 = myCookieColl.AllKeys
// Grab individual cookie objects by cookie name     
for(var i=0; i < arr1.Length; i++){
   myCookie = myCookieColl(arr1[i])
   Response.Write("Cookie: " + myCookie.Name + "<br>")
   Response.Write("Expires: " + myCookie.Expires + "<br>")
   Response.Write ("Secure:" + myCookie.Secure + "<br>")

   // Grab all values for single cookie into an object array.
   arr2 = myCookie.Values.AllKeys
   // Loop through cookie Value collection and print all values.
   for(var j=0; j < arr2.Length; j++){
      Response.Write("Value " + j + ": " + Server.HtmlEncode(arr2[j])
 + "<br>")
   }
}
  
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「HttpRequest.Cookies プロパティ」の関連用語

HttpRequest.Cookies プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



HttpRequest.Cookies プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS