C#

C#,Cookie Utility

这是Cookie的常用的方法,保存Cookie的值,获取Cookie的值,Function:

public class CookieUtil


{
public static void SaveCookie(HttpRequest request, HttpResponse response, string entry, string name, string value)
{
HttpCookie cookie = request.Cookies[entry];
if (cookie == null)
{
cookie = new HttpCookie(entry);
cookie.Expires = DateTime.Now.AddYears(10);
}
cookie[name] = value;
response.Cookies.Add(cookie);
}

public static string GetCookieValue(HttpRequest request, string entry, string name)
{
if (request.Cookies[entry] != null)
{
if (request.Cookies[entry][name] != null)
{
return request.Cookies[entry][name];
}
}
return null;
}
}

Pls call me CPP.
Posts created 150

发表评论

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top