Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have value that store on onclick of button to array once.

I click another value store in same array this array.

I want to store in cookie and when button is click first check if array of cookie contain any value if yes then next value added to same array otherwise it added to blank array .

please help asap its urgent
Posted
Updated 29-Sep-11 23:46pm
v2
Comments
RaisKazi 30-Sep-11 5:47am    
At least use full-stop(.), in your statements.

Hi,

In my view ..

same as timberbird

Because some browsers don't allow cookies.

If you want to store small amount of data like visited date like some other color...
you can follow this code for checking cookie is existing or not


C#
if (Request.Cookies.Count > 0)
{
    HttpCookieCollection hcc = Request.Cookies;
    string c1 = hcc[0].Value;
    Request.Cookies.Add(new HttpCookie("name", "value"));
}


So,my suggestion is don't develop process which is depends on cookies

All the Best
 
Share this answer
 
It's generally a bad idea to store arrays in cookies. Cookies may be cleared or disabled completely, and they are not intended to store potentially large volumes of data anyway. Consider using session or viewstate instead.
If, though, you really HAVE TO store array in cookies, just serialize it into string on first page and deserialize on the second.

There's also a possibility that I misunderstood your question (which would be no surprise, considering how obscure it is) and you just need to put two values in two absolutely different cookie values - which has nothing to do with dynamic arrays. Refine the question in this case
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900