I'm writing an asp.net application and I am saving the cookies correctly (stored in internet files). When I open the file it contains: access_token mylongalphanumberictoken /domainname (no spaces between them). The problem is that when I check the client for a cookie, I receive null. Can anyone tell me why this is happening and how do i fix it?
public void createCookie(string tokenVal)
{
authCookie = new HttpCookie("access_token",tokenVal);
authCookie.Expires = DateTime.Now.AddDays(60.00); //Token expires in 60 days
authCookie.Domain = ServerDomain.Authority;
}
check if the client has cookies like this:
if (Request.Cookies["access_token"] != null)
{
currentCookieStore.authCookie = Request.Cookies["access_token"];
}
EDIT: im using: currPage.Response.Cookies.Add(newTokenCookie.OauthCookie) ;
to add the cookies. ServerDomain is the location of my webserver so its machinename.domain
The answer is to add a P3P header to prevent IE from blocking your cookies. Solution here:
Explanation: Cookie blocked/not saved in IFRAME in Internet Explorer