can i add arraylist to cookies ? If yes how can i do it ?
I tried to add it in this manner :
Response.Cookies[“UserInfo”][“componentArrayList”] = componentArrayList;
But I’m getting error:
Cannot implicitly convert type ‘System.Collections.ArrayList’ to ‘string’
Please help me.
Thank you in anticipation
You can serialize this ArrayList with DataContractJsonSerializer, and store it as JSON, so later you can deserialize it and recover ArrayList’s state. Even in client-side code (JavaScript), for example with $.parseJSON jQuery function.
By the way, it’s a very bad idea to store an object in cookies, since data size limitation may vary, but it’s lower enough to avoid storing large sets of data.
You should consider using cookies to store identifiers and few limited user-specific client configuration, and use both to query server code for other, more specific data.