But you are trying to convert "test1" to a cookie. That is a string, not
a cookie. You must specifically create an instance of HttpCookie, fill in
its constructor or fields as needed, and then store it. I haven't used that
object myself, but the code would be something like this.
Dim allCookies As Generic.Dictionary(Of String, HttpCookie)
Dim oneCookie As HttpCookie
Dim i As Integer
For counter = 1 To 5
oneCookie = New HttpCookie
' !!! Fill in all of oneCookie's fields here, then...
allCookies.Add("test" & counter, oneCookie)
Next counter
-----
Tim Patrick - www.timaki.com
Start-to-Finish Visual Basic 2005
> Hi,
>
[quoted text clipped - 56 lines]
>>> cok(i) = Request.Cookies("??")
>>> nex
André - 29 Nov 2006 19:50 GMT
Ok, thanks
> But you are trying to convert "test1" to a cookie. That is a string, not a
> cookie. You must specifically create an instance of HttpCookie, fill in
[quoted text clipped - 75 lines]
>>>> cok(i) = Request.Cookies("??")
>>>> next
André - 29 Nov 2006 20:38 GMT
Tim, don't become angry (i'm learning), but it still doesn't work ...
If i do what you wrote here, i get an error with the line:
oneCookie = New HttpCookie
the error is: "overload resolution failed because no accessible 'new'
accepts this number of arguments"
so i tried this (and the error is gone): oneCookie = New HttpCookie("ok")
the whole code is:
Dim allCookies As New Generic.Dictionary(Of String, HttpCookie)
Dim i As Integer
Dim oneCookie As HttpCookie
For i = 1 To 5
oneCookie = New HttpCookie("ok")
oneCookie.Value = i
allCookies.Add("test" & i, oneCookie)
Next
But now, how can i retrieve the cookies? I did:
Dim allCookies As New Generic.Dictionary(Of String, HttpCookie)
Dim i As Integer
Dim cc(5) As String
Dim retCookie As HttpCookie
For i = 1 To 5
retCookie = allCookies("test" & i)
cc(i) = retCookie.Value
Response.Write(cc(i) & " ")
Next
And the error is now: "The given key was not present in the dictionary"
Can you help me a last time? Thanks
> But you are trying to convert "test1" to a cookie. That is a string, not a
> cookie. You must specifically create an instance of HttpCookie, fill in
[quoted text clipped - 75 lines]
>>>> cok(i) = Request.Cookies("??")
>>>> next
Tim Patrick - 30 Nov 2006 01:02 GMT
Since I'm not sure of what you are doing, I'm not fully sure of the answer
to give you. Cookies are normally only used in the context of a web page,
and ASP.NET exposes two collections of cookies, one through the Request object
and one through the Response object. I'm not sure why you want to create
your own disconnected set of cookies.
I would confirm that you have read up on the HttpCookie object and its related
HttpCookieCollection object (instead of Generic.Dictionary). HttpCookie has
its own name, so it seems a collection-specified name isn't really necessary.
Maybe if you could explain your purpose, it would make the problem easier
to diagnose.
-----
Tim Patrick - www.timaki.com
Start-to-Finish Visual Basic 2005
> Tim, don't become angry (i'm learning), but it still doesn't work ...
>
[quoted text clipped - 109 lines]
>>>>> cok(i) = Request.Cookies("??")
>>>>> next
André - 30 Nov 2006 22:00 GMT
Tim, it's ok, i think i understand it now ...
> Since I'm not sure of what you are doing, I'm not fully sure of the answer
> to give you. Cookies are normally only used in the context of a web page,
[quoted text clipped - 127 lines]
>>>>>> cok(i) = Request.Cookies("??")
>>>>>> next