HttpResponse.SetCookie(HttpCookie) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Because the HttpResponse.SetCookie method is intended for internal use only, you should not call it in your code. Instead, you can call the HttpResponse.Cookies.Set method, as the following example shows.
Updates an existing cookie in the cookie collection.
public:
void SetCookie(System::Web::HttpCookie ^ cookie);
public void SetCookie (System.Web.HttpCookie cookie);
member this.SetCookie : System.Web.HttpCookie -> unit
Public Sub SetCookie (cookie As HttpCookie)
Parameters
- cookie
- HttpCookie
The cookie in the collection to be updated.
Exceptions
Attempted to set the cookie after the HTTP headers were sent.
Examples
The following example updates the value of an existing cookie.
MyCookie.Value = DateTime.Now.ToString();
Response.Cookies.Set(MyCookie);
MyCookie.Value = CStr(DateTime.Now())
Response.Cookies.Set(MyCookie)
Applies to
See also
Commenti e suggerimenti
https://aka.ms/ContentUserFeedback.
Presto disponibile: Nel corso del 2024 verranno gradualmente disattivati i problemi di GitHub come meccanismo di feedback per il contenuto e ciò verrà sostituito con un nuovo sistema di feedback. Per altre informazioni, vedereInvia e visualizza il feedback per