ArrayList storing to a cookie

  • Thread starter Thread starter Maziar Aflatoun
  • Start date Start date
You can use the Values property of the cookie

ArrayList myArrayList = new ArrayList()
myArrayList.Add("test")
myArrayList.Add("test2")
myArrayList.Add("Test")
HttpCookie myCookie = new HttpCookie("Test")
for (int i = 0; i < myArrayList.Count;i++

myCookie.Values["Value"+i.ToString()] = myArrayList.ToString()

Response.Cookies.Add(myCookie)

Marinus
 
Hi Maziar,

I have just made this sample for you how to serialize and deserialize an
arraylist.
(make a string from an arraylist and visa versa)

You can try that.

I hope it helps?

Cor
\\\
Private Function SerializeArraylist(ByVal _
arraylst As ArrayList) As String
Dim bf As New
Runtime.Serialization.Formatters.Binary.BinaryFormatter
Dim mem As New IO.MemoryStream
bf.Serialize(mem, arraylst)
Return Convert.ToBase64String(mem.ToArray())
End Function
Private Function DeserializeArraylist(ByVal _
arraystring As String) As ArrayList
Dim bf As New
Runtime.Serialization.Formatters.Binary.BinaryFormatter
Dim mem As New
IO.MemoryStream(Convert.FromBase64String(arraystring))
Return DirectCast(bf.Deserialize(mem), ArrayList)
End Function
///
 
Back
Top