C#中Cookie乱码问题解决办法
2008年04月25日 15:02
c#写法
写COOKIE: HttpCookie acookie = New HttpCookie(user); acookie.Values.Add("user", HttpUtility.UrlEncode(user)); '写COOKIE时进行编码 acookie.Values.Add("pass", HttpUtility.UrlEncode(pass)); Response.Cookie(acookie); 读COOKIE: HttpCookie acookie = Request.Cookies(user); Session["user"] = HttpUtility.UrlDecode(acookie.Values["user"].ToString()); Session["pass"] = HttpUtility.UrlDecode(acookie.Values["pass"].ToSring()) ; '读COOKIE时进行解码 |