MasterPages and Cookies

I am trying to create a cookie using the masterpages.  The site that reads the cookie doesn't see it.  They are both in the same domain.  I am creating the cookie in the load event.  The  cookie isn't being created.  Here is my code:

 

 

HttpCookie aCookie = new HttpCookie("DDPASecurity");

aCookie.Values["Auth"]="user@domain.com";

aCookie.Domain="domain.com";

aCookie.Expires = DateTime.Now.AddDays(1);

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Did you add your Persist

Did you add your Persist Cookie Object into Response object for future use?

ref: http://www.c-sharpcorner.com/UploadFile/annathurai/518/Default.aspx

 

Yes, Here is that

Yes, Here is that part:

Response.Cookies.Add(aCookie);

What happens if you don't

What happens if you don't specify domain name? Is it working?

No, I get this

No, I get this error:

Object reference not set to an instance of an object.