------解决方案-------------------- 引用Imports System.Web
Public Shared Function getCookie(ByVal name As String) As String
Dim Cookie As HttpCookie = HttpContext.Current.Request.Cookies(name)
If Cookie Is Nothing Then
Return ""
Else
Return HttpUtility.UrlDecode(Cookie.Value)
End If
End Function
Public Shared Sub setCookie(ByVal name As String, ByVal value As String)
HttpContext.Current.Response.Cookies.Add(New System.Web.HttpCookie(name, HttpUtility.UrlEncode(value)))
End Sub ------解决方案--------------------
public static void SetCookie(HttpResponseBase Response,string CarValue)
{
string CookieName = username; //car name
int CarCookieExpires = 30; //Expires
Response.Cookies.Add(new HttpCookie(CookieName, CarValue));
Response.Cookies[CookieName].Expires = DateTime.Now.AddDays(CarCookieExpires); //保存1月
}
------解决方案--------------------
修正一下。
public static void SetCookie()
{
string CookieName = username; //car name
int CarCookieExpires = 30; //Expires
Response.Cookies.Add(new HttpCookie(CookieName,"aa"));
Response.Cookies[CookieName].Expires = DateTime.Now.AddDays(CarCookieExpires); //保存1月