SgDotNet
Singapore Professional .NET User Group -For Cool Developers

Auth cookie domain assignment

rated by 0 users
This post has 3 Replies | 1 Follower

Top 10 Contributor
Posts 2,257
icelava Posted: 09-25-2004 10:59 PM
By default the Login/Logout mechanism simply uses the FormsAuthentication auth methods to establish the auth cookie. That means the domain tied to the cookie is according to the FQDN requested by the client.

Triplez has requested the cookie domain be "hard coded" down to "sgdotnet.org" so it may be usable on the main site. Well I adjusted the code to make use of the domain specific in the SiteSettings

Login.cs : LoginButton_Click()
// Assign auth cookie to site domain instead of Forums FQDN.
HttpCookie cookie = FormsAuthentication.GetAuthCookie(userToLogin.Username, autoLogin.Checked);
if (forumContext.Context.Request.UserHostAddress != "127.0.0.1")
   cookie.Domain = Globals.GetSiteSettings().CookieDomain;
forumContext.Context.Response.Cookies.Set(cookie);


Logout.cs : InitializeSkin()
if (forumContext.Context.Request.UserHostAddress == "127.0.0.1")
   FormsAuthentication.SignOut();
else
{
   HttpCookie cookie = forumContext.Context.Request.Cookies[FormsAuthentication.FormsCookieName];
   cookie.Domain = Globals.GetSiteSettings().CookieDomain;
   cookie.Expires = DateTime.Now.AddDays(-1);
   forumContext.Context.Response.Cookies.Add(cookie);
}

The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral

Top 10 Contributor
Posts 2,870
Just want to add... those having trouble logging in, pls delete ur existing cookies, as triplez has adviced me to do...

Best Regards, Kit Kai, MVP (SharePoint Portal Server)

Top 10 Contributor
Posts 2,257
It is more likely others will read this thread
http://forums.sgdotnet.org/ShowPost.aspx?PostID=4969

rather than this one.

The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral

Top 10 Contributor
Posts 2,257

I realise the new Logout.cs for Community Server was not updated leading to the problem of being unable to logout in a loop.

I have re-adjusted that.

The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral

Page 1 of 1 (4 items) | RSS
Copyright SgDotNet 2004-2008
Powered by Community Server (Commercial Edition), by Telligent Systems