We help IT Professionals succeed at work.

vb.net Cookie value is one number, but inserts into database as another number?

Hello All;

I am having a cookie issue.
(This is in a server farm, I am not sure if that makes to much of a difference, as the Cookie is saved on the client's system and not on the server(s).)
And the screenshot below, you can see the value is (3)
However, when I try to read it into the SQL Query from a vb.net script, it inserts the number (2)
The Cookie is created with this.
Response.Cookies.Set(New HttpCookie("theAlbumCookie", rsAlbum("AlbumID")))

Open in new window

The Cookie is then read with this.
Request.Cookies("theFArtistCookie").Value)

Open in new window


A response.write, gives the correct value. (Sometimes, as I found out a little later on after posting this)
                
Response.Write(Request.Cookies("theAlbumCookie").Value)
Response.End()

Open in new window


I ran a test real quick and it inserted the correct number.
Then I uploaded another song from another album, and it inserted the number from the previous album, even though the cookie Value is for the current album, which in this case, will be a (4)

Can someone please let me know what is causing it to read the Cookie as a different value, when, as seen in the screenshot, it is a (3)
Cookie Properties
Thanks.
Wayne
Comment
Watch Question

Author, Web Developer
CERTIFIED EXPERT
Top Expert 2009
Commented:
OK, just laid down in bed, and I thought about something.
DELETE THE COOKIE AND RECREATE IT!
So, I jumped back into it, and at the end of the process, I added this.

            dim DelCookie as httpcookie
            DelCookie = New HttpCookie("theAlbumCookie")
            DelCookie.Expires = DateTime.Now.AddDays(-1D)
            Response.Cookies.Add(DelCookie)

I then created a new SqlDataReader
Of which checks if the album exists, and if it does, it creates the cookie with the correct value.

That's it.
It seems always to work out this way when I am getting ready to go to sleep.
I hope this helps out others.
Wayne