HttpListenerResponse.SetCookie メソッド
アセンブリ: System (system.dll 内)



Name、Domain、および Path の各プロパティの値が同じ場合、2 つの Cookie は同じと見なされます。これらの 3 つの情報が同じ場合、このメソッドは Cookie を更新しようとします。名前とドメインの比較では大文字と小文字が区別されませんが、パスの比較では大文字と小文字が区別されます。

メソッドの呼び出しについては、次のコード例を参照してください。
// This example requires the System and System.Net namespaces. public static void SimpleCookieExample(string[] prefixes) { // Create a listener. HttpListener listener = new HttpListener(); // Add the prefixes. foreach (string s in prefixes) { listener.Prefixes.Add(s); } listener.Start(); Console.WriteLine("Listening..."); // Note: The GetContext method blocks while waiting for a request. HttpListenerContext context = listener.GetContext(); HttpListenerRequest request = context.Request; // This application sends a cookie to the client marking the time // they visited. Cookie timeStampCookie = new Cookie("VisitDate", DateTime.Now.ToString()); // Obtain a response object. HttpListenerResponse response = context.Response; // Add the cookie to the response. response.SetCookie(timeStampCookie); // Construct a response. string responseString = "<HTML><BODY> Hello world!</BODY></HTML>"; response.ContentEncoding = System.Text.Encoding.UTF8; byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); // Send the response. response.Close(buffer, true); listener.Stop(); }

Windows 98, Windows Server 2003, Windows XP Media Center Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からHttpListenerResponse.SetCookie メソッドを検索する場合は、下記のリンクをクリックしてください。

- HttpListenerResponse.SetCookie メソッドのページへのリンク