Επεξεργασία

Κοινή χρήση μέσω


HttpResponse.AppendCookie(HttpCookie) Method

Definition

Adds an HTTP cookie to the intrinsic cookie collection.

public:
 void AppendCookie(System::Web::HttpCookie ^ cookie);
public void AppendCookie (System.Web.HttpCookie cookie);
member this.AppendCookie : System.Web.HttpCookie -> unit
Public Sub AppendCookie (cookie As HttpCookie)

Parameters

cookie
HttpCookie

The HttpCookie to add to the output stream.

Exceptions

A cookie is appended after the HTTP headers have been sent.

Examples

The following example creates a new cookie named LastVisit, sets the value of the cookie to the current date and time, and appends the cookie to the current cookie collection. All cookies in the cookie collection are sent to the client in the Set-Cookie header with the HTTP output stream.

HttpCookie MyCookie = new HttpCookie("LastVisit");
 MyCookie.Value = DateTime.Now.ToString();
 Response.AppendCookie(MyCookie);

Dim MyCookie As New HttpCookie("LastVisit")
 MyCookie.Value = CStr(DateTime.Now())
 Response.AppendCookie(MyCookie)
    

Applies to