HTTP Cookieとは? わかりやすく解説

HttpCookie クラス

HTTP cookie のそれぞれタイプ セーフ方法作成および操作できるようにします。

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

Public NotInheritable Class
 HttpCookie
public sealed class HttpCookie
public final class HttpCookie
解説解説
使用例使用例

HttpRequest オブジェクト内の DateCookieExample という名前の Cookie確認する方法次のコード例示します。この Cookie は、見つからない場合には作成されHttpResponse オブジェクト追加されます。この Cookie有効期限10 分に設定されています。

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub Page_Load(ByVal
 sender As Object, ByVal
 e As System.EventArgs)
        Dim sb As New StringBuilder()
        ' Get cookie from current request.
        Dim cookie As HttpCookie
        cookie = Request.Cookies.Get("DateCookieExample")
        
        ' Check if cookie exists in the current request
        If (cookie Is Nothing)
 Then
            sb.Append("Cookie was not received from the client.
 ")
            sb.Append("Creating cookie to add to the response.
 <br/>")
            ' Create cookie.
            cookie = New HttpCookie("DateCookieExample")
            ' Set value of cookie to current date time.
            cookie.Value = DateTime.Now.ToString()
            ' Set cookie to expire in 10 minutes.
            cookie.Expires = DateTime.Now.AddMinutes(10D)
            ' Insert the cookie in the current HttpResponse.
            Response.Cookies.Add(cookie)
        Else
            sb.Append("Cookie retrieved from client. <br/>")
            sb.Append("Cookie Name: " + cookie.Name
 + "<br/>")
            sb.Append("Cookie Value: " + cookie.Value
 + "<br/>")
            sb.Append("Cookie Expiration Date: " &
 _
                cookie.Expires.ToString() & "<br/>")
        End If
        Label1.Text = sb.ToString()

    End Sub
</script>

<html  >
<head runat="server">
    <title>HttpCookie Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:Label id="Label1" runat="server"></asp:Label>
    
    </div>
    </form>
</body>
</html>
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    protected void Page_Load(object sender,
 EventArgs e)
    {
        StringBuilder sb = new StringBuilder();
        // Get cookie from the current request.
        HttpCookie cookie = Request.Cookies.Get("DateCookieExample");
        
        // Check if cookie exists in the current request.
        if (cookie == null)
        {
            sb.Append("Cookie was not received from the client. ");
            sb.Append("Creating cookie to add to the response. <br/>");
            // Create cookie.
            cookie = new HttpCookie("DateCookieExample");
            // Set value of cookie to current date time.
            cookie.Value = DateTime.Now.ToString();
            // Set cookie to expire in 10 minutes.
            cookie.Expires = DateTime.Now.AddMinutes(10d);
            // Insert the cookie in the current HttpResponse.
            Response.Cookies.Add(cookie);
        }
        else
        {
            sb.Append("Cookie retrieved from client. <br/>");
            sb.Append("Cookie Name: " + cookie.Name + "<br/>");
            sb.Append("Cookie Value: " + cookie.Value + "<br/>");
            sb.Append("Cookie Expiration Date: " + 
                cookie.Expires.ToString() + "<br/>");
        }
        Label1.Text = sb.ToString();
    }
</script>

<html  >
<head runat="server">
    <title>HttpCookie Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:Label id="Label1" runat="server"></asp:Label>
    </div>
    </form>
</body>
</html>
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
  System.Web.HttpCookie
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HttpCookie メンバ
System.Web 名前空間
HttpResponse
HttpRequest
HttpCookieCollection

HttpCookie コンストラクタ (String)


HttpCookie コンストラクタ

HttpCookie クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
HttpCookie (String) 新しcookie作成し、名前を付けます
HttpCookie (String, String) 新しcookie作成し、名前を付け、値を割り当てます
参照参照

関連項目

HttpCookie クラス
HttpCookie メンバ
System.Web 名前空間

HttpCookie コンストラクタ (String, String)

新しcookie作成し、名前を付け、値を割り当てます

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

使用例使用例

新しCookie作成し、名前を付け、値を設定するコード例次に示します

Dim MyCookie As New HttpCookie("LastVisit",
 CStr(DateTime.Now()))
    
HttpCookie MyCookie = new HttpCookie("LastVisit", 
    DateTime.Now.ToString());
    
HttpCookie myCookie = 
    new HttpCookie("LastVisit", DateTime.get_Now().ToString());
var myCookie : HttpCookie = new HttpCookie("LastVisit",
 String(DateTime.Now))
    
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

HttpCookie プロパティ


HttpCookie メソッド


HttpCookie メンバ

HTTP cookie のそれぞれタイプ セーフ方法作成および操作できるようにします。

HttpCookie データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

HttpCookie クラス
System.Web 名前空間
HttpResponse
HttpRequest
HttpCookieCollection

HTTP cookie

出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2024/02/22 06:14 UTC 版)

HTTP cookie(エイチティーティーピークッキー)は、マジッククッキーの一種。単にクッキーcookie)とも表記される。


  1. ^ ここで言う資源とは、HTML文書や画像、音声、などのコンテンツ全般を指す。
  2. ^ ウィキペディアを例に挙げると、同じURLでもログインしていない場合はページの一番上が「ログインまたはアカウント作成」、している場合は「(ユーザ名) 自分の会話 個人設定 ウォッチリスト 自分の投稿記録 ログアウト」と表示が変化する。
  3. ^ Netscape Communications Corporation. “PERSISTENT CLIENT STATE HTTP COOKIES” (英語). 2011年9月29日閲覧。
  4. ^ Dan Winship. “2009-08-05-Dan-Winship.txt” (英語). 2011年9月29日閲覧。
  5. ^ Dan Winship. “2009-08-11-Dan-Winship.txt” (英語). 2011年9月29日閲覧。
  6. ^ draft-ietf-httpbis-rfc6265bis-06
  7. ^ Can I use: headers HTTP header: Set-Cookie: Cookie prefixes
  8. ^ Can I use: 'SameSite' cookie attribute
  9. ^ Microsoft. “[IIS]2038 年 1 月 19 日以降の有効期限のクッキーにおける ASP 200 エラー”. 2008年6月16日閲覧。
  10. ^ 情報処理推進機構. “経路のセキュリティと同時にセキュアなセッション管理を”. 2008年5月24日閲覧。
  11. ^ Symantec Corporation. “システムの完全スキャンを実行するとトラッキング・クッキーのリスクが表示される”. 2008年6月15日閲覧。
  12. ^ Trend Micro Incorporated. “スパイウェア検索をすると「COOKIE_・・・・」が多量に検出されるのですが、大丈夫ですか?”. 2008年6月15日閲覧。 [リンク切れ]
  13. ^ “アドネットワークは、常にあなたを監視している”. japan.internet.com. (2011年10月25日). http://japan.internet.com/wmnews/20111025/5.html 2011年10月26日閲覧。 
  14. ^ Fingerprint解説サイト - 明治大学 情報セキュリティ研究室
  15. ^ NTTコムオンライン”. NTT. 2023年1月30日閲覧。




英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「HTTP Cookie」の関連用語

HTTP Cookieのお隣キーワード
検索ランキング

   

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



HTTP Cookieのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.
ウィキペディアウィキペディア
All text is available under the terms of the GNU Free Documentation License.
この記事は、ウィキペディアのHTTP cookie (改訂履歴)の記事を複製、再配布したものにあたり、GNU Free Documentation Licenseというライセンスの下で提供されています。 Weblio辞書に掲載されているウィキペディアの記事も、全てGNU Free Documentation Licenseの元に提供されております。

©2024 GRAS Group, Inc.RSS