View Full Version : Can I use Cookies as Data Files??

07-05-2002, 11:27 AM
Hi, I'm a new user and just have a big problem! When I learned cookies, I just thought can I use it like files in C++ or not. I mean putting too much values in them and then retrieving them?

I wana have an input box with two buttons : Enter and Display.
The user enters new names in the text area, I put them in the cookie with the setCookie function, and then when he/she clicks on the Display button, I retrieve all the names from the cookie file and show them in a new window, in the following manner:

Name #1 : .........
Name #2 : .........
Name #3 : .........

My Solution:

I make my setCookie function, then I call it as setCookie("Number", count, CD() ), "Number" is the name of my variable that never changes, but 'count' holds the number of names' elements. Also CD() is a function that calculates the date of the next year. Then whenever I wana add something to the cookie, I get the value of "Number" by using ( count = getCookie("Number") ), then inceremening count by one, and entering my new data as ( setCookie("Name" + count, Value, CD() ) ).
But it doesn't work, I have the whole program written and I'm gonna send it now, I put enough description in that, so, saying more here will make it confusing!

Please take a look at the file and tell me what I can do! thanx in advance...