Last post Nov 08, 2013 12:57 PM by markfitzme
Nov 05, 2013 01:59 AM|melvintcs|LINK
i use code below to test the cookies. it works fine at localhost. i also can find the value inside the cookies file located at C:\Users\user\AppData\Local\Google\Chrome\User Data\Default\Cookies
but after i upload to server, the value is found on page load:
after postback or use another page to retrieve the cookie, Error Message: "Object reference not set to an instance of an object." occurs
and the value also not store inside my local cookie file.
what should i do? please advice me?
public void add()
HttpCookie _userInfoCookies = new HttpCookie("CookiesTesting");
_userInfoCookies.Value = "abcdefgh";
_userInfoCookies.Expires = DateTime.Now.AddDays(1d);
public void request()
I did some research and they suggest to store the value into the sql instead of cookies.
but i dun think it's suitable for my case, because i need to check for the availability of the value like every 5-10 sec.
Nov 05, 2013 05:07 AM|Siva Krishna Macha|LINK
I think, you would need to set the Domain property to resolve your issue.
HttpCookie class has the Domain property.
Nov 08, 2013 12:57 PM|markfitzme|LINK
Well, which line are you getting an object reference error at? Have you checked to make sure it isn't just happening before you call your add method which would prevent the add method from ever running and thus the cookie from not getting stored?