【发布时间】:2011-05-16 05:00:39
【问题描述】:
为什么这个 cookie 没有保存在我的 global.asax 的 Session_Start 方法中?
//new anon user:
var authCookie = new HttpCookie("user-id", string.Format("{0}-{1}", regiserAccountResponse.UserName, regiserAccountResponse.Key))
{
Expires = DateTime.MaxValue,
Domain = "domain.com",
Secure = true,
HttpOnly = true
};
//create the new users cookie - there's no need to call RegisterNewUserSession as this is done in the same call
HttpContext.Current.Response.SetCookie(authCookie);
【问题讨论】:
-
你如何检测它是否真的被保存了?您是否使用过 Wireshark 来查看它是否正在下降?您是否修复了域和安全位以反映现实?
-
在我准备好部署之前是否应该将域留空?还是在我部署之前应该是本地主机?
-
尝试完全删除它。这不像您真的在为“domain.com”服务,是吗?我不能说我对 cookie 了解多少,但这些设置看起来肯定是错误的......
-
感谢 jon - remd 安全和域道具,它现在似乎可以工作了 - 如果你将它添加到答案中,我会将其标记为正确 :)
标签: c# asp.net-mvc cookies