The cookie should show up under the domain name you are hitting in your
temporary internet files. You have to refresh the folder after hitting the
page to see the cookie (a bit strange compared to other folders, but many of
the profile folders are not standard windows folders).
You cannot access the cookies until you redirect as the information is not
sent to the server until it is requesting another page. As it works, you are
definitely getting the cookie through.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
*************************************************
Think outside the box!
*************************************************
"Groove" <> wrote in message
news:%...
> Hey guys - hoping you can help me out here. I'm using asp.net 2 (VB) and
> trying to set and retrieve values from a cookie. I've done this a few
> times before w/o a problem but I seem to be overlooking something here.
> I'm even following my previous working examples and I can't see the
> different.
>
> I have a page that will remember the user's settings using a cookie. Ther
> Calendar Events, recent orders, etc will be displayed or hidden based upon
> the checkboxes they select (but I haven't gotten that far yet). I'm
> getting an error at:
>
> Object reference not set to an instance of an object.
> strMyEvents = objCookie.Values("MyEvents")
>
> After using the code below, I tried to search the PC for a cookie and
> couldn't find it which makes me think it doesn't exist. Yet, when I
> response.redirect the value of the cookie just to test, it indeed finds
> "True"
>
> Any ideas??
>
> Here's a simplified version of my code:
>
>
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs)
>
> If Page.IsPostBack = False Then
>
> Dim objCookie As HttpCookie
> Dim strMyEvents As String
>
> objCookie = Page.Request.Cookies("Intranet")
>
>
> If IsNothing(objCookie) = True Then
> SetCookie("True")
> End If
>
>
> strMyEvents = objCookie.Values("MyEvents")
>
> lblTest.Text = strMyEvents
>
>
> End If
>
> End Sub
>
>
>
>
>
> Protected Sub SetCookie(ByVal strMyEvents As String)
>
> Dim objCookie As HttpCookie
>
> objCookie = New HttpCookie("Intranet")
> objCookie.Expires = DateTime.MaxValue
>
> objCookie.Values("MyEvents") = "True"
>
> 'Response.Redirect(objCookie.Values("MyEvents"))
>
>
> End Sub
>