【发布时间】:2016-10-07 09:04:20
【问题描述】:
我通过以下方式收集数据并使用 POST 请求在服务器上设置 cookie:
HttpCookie cookies = new HttpCookie(name) {
Value = value,
Expires = DateTime.MaxValue,
Secure = true };
HttpContext.Current.Response.Cookies.Remove(name);
HttpContext.Current.Response.Cookies.Add(cookies);
POST 请求完成后,我使用 js 重新加载页面。 我为该页面使用了 cookie 中的一些值。
我试着让他们喜欢:
if (HttpContext.Current.Request.Cookies[NameCookieName] != null)
{
name = HttpContext.Current.Request.Cookies[NameCookieName].Value;
}
if (HttpContext.Current.Request.Cookies[RegionCookieName] != null)
{
region = HttpContext.Current.Request.Cookies[RegionCookieName].Value;
}
如果我使用 HTTP,它工作正常。
当我使用 HTTPS cookie 集时,但当我读取它们时,cookie 的值为 NULL。
如何使用 HTTPS 设置/获取 cookie?
【问题讨论】:
标签: .net asp.net-mvc cookies https