1

I am using forms authentication to handle SSO across *.mydomain.com Upon login i create a non-persistant cookie with the ticket embedded in it and set it's domain to .mydomain.com.

However the problem is that when i visit any website on the domain, i find there are two cookie with the same name but with different domains. :

1> site1.mydomain.com [1st Forms Auth Cookie] duplicate cookie

2> .mydomain.com[2nd Forms Auth cookie]

enter image description here

The 1st Cookie is not created by me.Also it isn't secure.

Upon logout i successfully clear my 2nd Cookie.

However, the 1st cookie remains and for a user it appears that he is still logged in to site1 . This happpens because i check for the existence of the cookie with the same name and surely the 1st cookie is wrongly assumed to be the Forms Auth Cookie. I cannot check the domain property because in the Request the information about the domain is null .

My issue is how is the second website-specific domain cookie is getting created. If i cannot avoid this, is there a workaround?

UPDATE : The encrypted value stored by this faulty cookie is updated on each request i make on the website,while the encrypted value in my Auth Cookie remains same

1 Answer 1

1

According to MSFT Docs

"The Add method allows duplicate cookies in the cookie collection. Use the Set method to ensure the uniqueness of cookies in the cookie collection."

After renewing my Forms Authentication ticket i was doing :

Response.Cookies.Add(..);

Thus a new duplicate cookie was getting generated.

To fix this do :

Response.Cookies.Set(..); 

If you were like me you would have expected ASP.Net to replace the old cookie with the new one.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.