I just realized that this cookie is not showing up like it should, and I checked the code which was not written by me but I am pretty sure that this is NOT enough to create a cookie right??
public static void CreateSSOCookies(string tokenID)
{
System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Domain = System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToString().ToLower();
System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Value = tokenID.ToString();
System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Path = "~/";
System.Web.HttpContext.Current.Response.Cookies["ssocookies"].Expires = DateTime.Now.AddDays(7);
}
If it does work, where is the cookie then? Is the cookie name ‘ssocookies’ ?
I must admit I didn’t know, but apparently it does create a cookie. I’ve tested it, it works.
See http://msdn.microsoft.com/en-us/library/78c837bd.aspx
So far I had always used the
new HttpCookie()method, which seems much .NET-like to me than a collection magically adding a cookie with the right name on first reference. I would still recommend being more explicit about creating the cookie like that, especially seeing some of the incorrect answers here 🙂Edit:
The path “~/” is indeed probably not what you want. Use
instead.