PDA

Click to See Complete Forum and Search --> : Am i missing something here with cookies


carlblanchard
May 20th, 2004, 12:36 PM
OK back in the normal asp days setting and reading a cookie was so dam simple

response.cookies("blah") = blah &
request.cookies("blah")

ok now the .net way (*** is that all about)

ok heres my real question

i have a control which handles the left hand side of my website on here ive got a littie area which displays users shopping cart so therefore i store the users cart id in the cookie,

when ever i load the index page is get this error


If Request.Cookies("CartCookie").Value >= 0 Then


Object reference not set to an instance of an object.


its because i havnt defined the NEW part of the cookie...
So if i do instead



Dim cookie As HttpCookie = New HttpCookie("CartCookie")
if cookie.value > 0 then


It allows me to run the page without errors, however every time i add to the cart its panel in this control is never displayed....

Now am i just being thick or what

nemaroller
May 20th, 2004, 12:52 PM
Perhaps the real question is whether that code is executing before the page has finished loading its controls and state.

What event does that code run in your user control?

carlblanchard
May 20th, 2004, 01:05 PM
onLoad

nemaroller
May 20th, 2004, 05:21 PM
Normally I would say try the PreRender event, but that shouldn't make a difference for the Request object.

You stated assigning a new instance worked, but weren't too clear about 'its panel' not displaying...?