C# 之 Cookie 接收方法
撰寫 Cookie (Visual C#)
client端建立cookie
HttpCookie myCookie = new HttpCookie("MyTestCookie");
// Set the cookie value.
myCookie.Value = 放你想要的數值;
DateTime now = DateTime.Now;
myCookie.Expires = now.AddMinutes(1); <--- ookie="" p="">// Add the cookie.
Response.Cookies.Add(myCookie); <----client cookie="" p="">
------------------------------------------------------------------------------------------------------------------
Server接收cookie
HttpCookie myCookie = new HttpCookie("MyTestCookie");
myCookie = Request.Cookies["MyTestCookie"];
// Read the cookie information and display it.
string result = myCookie.Value; <--- p="">--->----client>--->
client端建立cookie
HttpCookie myCookie = new HttpCookie("MyTestCookie");
// Set the cookie value.
myCookie.Value = 放你想要的數值;
DateTime now = DateTime.Now;
myCookie.Expires = now.AddMinutes(1); <--- ookie="" p="">// Add the cookie.
Response.Cookies.Add(myCookie); <----client cookie="" p="">
------------------------------------------------------------------------------------------------------------------
Server接收cookie
HttpCookie myCookie = new HttpCookie("MyTestCookie");
myCookie = Request.Cookies["MyTestCookie"];
// Read the cookie information and display it.
string result = myCookie.Value; <--- p="">--->----client>--->
留言
張貼留言