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
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de l’année 2024, nous abandonnerons progressivement le mécanisme de retour d’information GitHub Issues pour le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultez :Soumettre et afficher des commentaires pour