0

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

artifex_somnia
  • 398
  • 5
  • 18
  • Could you ensure the cookie is added to the response like `Response.Cookies.Add(authCookie);`? What is `ServerDomain`, and where did you access that cookie? – Win Aug 20 '14 at 16:22
  • im using currPage.Response.Cookies.Add(newTokenCookie.OauthCookie) to add the cookies. ServerDomain is the location of my webserver so its machinename.domainname.com – artifex_somnia Aug 20 '14 at 16:49