开发者

Limiting Cookie Domain Scope in asp.net mvc3

I want to set the scope of cookies on subdomain level for single sign on. I found below piece of code on MSDN to set the scope for cookies @ http://msdn.microsoft.com/en-us/library/ms178194.aspx#Y2930

Response.Cookies["domain"].Value = DateTime.Now.ToString();
Response.Cookies["domain"].Expires = DateTime.Now.AddDays(1);
Response.Cookies["d开发者_如何学Comain"].Domain = "contoso.com";

But I don't know where to write this piece of code, in global.asax? any thoughts.


Application_PostAuthenticateRequest() is a rather obvious choice I think.

You have authenticated the user at Application_AuthenticateRequest, and you can then go on to modify the cookies domain.

http://msdn.microsoft.com/en-us/library/system.web.httpapplication.postauthenticaterequest.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜