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
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈