Click to See Complete Forum and Search --> : Cookies


David Harrison
07-17-2003, 02:16 PM
I've never used cookies before so I was wondering how would I go about storing an array of data in a cookie?

Khalid Ali
07-17-2003, 02:21 PM
I don't think you can store objects in a cookie,however you can use string vlues in a cookie and then retrieve them and create an array of those values...

David Harrison
07-17-2003, 02:23 PM
Isn't an array just a lot of strings all with similar names?

If so, couldn't it be done with a for loop?

Khalid Ali
07-17-2003, 03:05 PM
Array is like that but JavaScript engine knows that...I have never tried to put array in cookie in a hope that it will automatically figure it out..you can always try..:D

David Harrison
07-17-2003, 03:13 PM
Well, could you show me how to put anything into a cookie, because like I said, I've never used cookies before.

Khalid Ali
07-17-2003, 03:41 PM
Here you go,its prety simple script that uses cookies

http://68.145.35.86/skills/javascripts/SimpleLoginCookieScript.html

David Harrison
07-17-2003, 03:55 PM
Thanks for the example.

Now my next question is do cookies get deleted once the browser window is closed, or is that only if an expiration date isn't specified.

Khalid Ali
07-17-2003, 03:59 PM
yes you do need to set a cookie expiration date....

David Harrison
07-17-2003, 04:04 PM
OK, thanks for all the help, I'll go away and work on it now.