PDA

View Full Version : Save and load information from a cookie.



queerfm
02-15-2007, 03:43 PM
Hi i am trying to make a drop down box with a number of countrys or laguages.

I would like to save the information in a cookie file. So that the user does not have to put the information in each time they come to the site.

I would like to cookie to last for 4 week if possible.

Thanks any help welcome.
also here is a demo of what i am looking for but i would like it to be ether php or html - http://www.ten.com.au

thetestingsite
02-16-2007, 02:50 AM
Take a look at this thread:

http://www.dynamicdrive.com/forums/showthread.php?t=16544

this should give you an idea of how to accomplish this. If not, let me know what you've got so far and I will see if I can help you out anymore.

codeexploiter
02-16-2007, 03:37 AM
If you are looking for a way to handle cookies using JavaScript then I would suggest reading this page (http://www.quirksmode.org/js/cookies.html).

It is very useful as it contains three functions which you can use in your case for the following purposes:

(1) Creating a cookie
(2) Reading a cookie
(3) Erasing a cookie

I found these functions very simple and used in my scripts.


but i would like it to be ether php or html

I wonder what is PHP and HTML is doing in JavaScript area of the forum :D

queerfm
02-16-2007, 06:53 AM
well i thought it would be javascript. But if not thats cool

jscheuer1
02-16-2007, 04:53 PM
The cookie unit at quirksmode (http://www.quirksmode.org/js/cookies.html) linked to codeexploiter's post and this one is javascript. It works quite well in most situations. But, it is javascript. This means that the user can turn off either javascript or just javascript cookies. It also means that the cookie is stored on the user's machine where he or she can edit or delete it, and where hackers can steal it. There are also PHP cookies - server side cookies and these are better for secure data. In fact, some sort of server side cookie is the only type of cookie that should be used with secure data and then only on a secure server. HTML has no cookies.