473,320 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

ArrayList storing to a cookie

Hi,

Does anyone know how I can store an ArrayList in a cookie?

Thank you
Maz.
Nov 22 '05 #1
2 3942
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[i].ToString()

Response.Cookies.Add(myCookie)

Marinus
Nov 22 '05 #2
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.BinaryForm atter
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.BinaryForm atter
Dim mem As New
IO.MemoryStream(Convert.FromBase64String(arraystri ng))
Return DirectCast(bf.Deserialize(mem), ArrayList)
End Function
///
Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Francisco | last post by:
I have this problem: I have a database with information about games, and users are able to vote for them. Everytime a user votes for a game I store the unique game name into a session variable (an...
1
by: Blossom | last post by:
Hi there, I have a problem with storing my Cookies. I made a servlet in which I store a Cookie (in the doGet()-method) to detect whether a user has already visited my webpage. I used the...
4
by: Brian Burgess | last post by:
Hi all, Anyone know of any special issues with storing cookies with ASP? I'm trying this with two browsers: One is IE 6.0 with cookies set to 'prompt'. This has been working properly as any...
4
by: Stuart | last post by:
I have a small class of data values made up of ints and bools totalling 25 bytes. Each of these 25 byte nodes is stored in another class as an ArrayList with a few more ints. Typically there are...
1
by: Maziar Aflatoun | last post by:
Hi, Does anyone know how I can store an ArrayList in a cookie? Thank you Maz.
2
by: jakk | last post by:
Iam storing the session state in SQL Server. The Session gets stored in the SQL Server temp tables ( I can see some values in the two tables), but the session doesnt seem to timeout. We have a...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
44
by: Zytan | last post by:
The docs for List say "The List class is the generic equivalent of the ArrayList class." Since List<is strongly typed, and ArrayList has no type (is that called weakly typed?), I would assume...
4
by: =?Utf-8?B?YmFzdWxhc3o=?= | last post by:
Hi; I want to store a datatable (or an arraylist) as a session variable but when I try; Session = al_RecNo; I get an error that; "Cannot implicitly convert type...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.