View Full Version : How do you make a cookie?

10-19-2005, 04:09 PM
I want to make a simple (VERY simple) cookie that will be placed on my visitors browser when they visit one specific page (NOT the index)

I have read and googled and read and googled and my eyes are about to pop out.

I found a cookie writing program, and I wrote a cookie code that includes the information I want in the cookie.

What I can NOT figure out, is how to impliment the cookie code into a specific page. Is the cookie its own page? Do I need to make a cookie file? do I need to add code to a .htm page? How does this get put into a cache on someone elses computer?

EXAMPLE: Visitor browses site and ends up going to www.mysite.com/chocolatechip/peanutbutter.htm

when they go to this page I want the cookie to be added to their cache then, and only then.

Is this possible? I know it is, or else I wouldn'thave to clean out my cookies folder all the time... but how do I do it?


10-19-2005, 04:25 PM

10-19-2005, 05:45 PM
Hee he hee. Thanks Twey, now, to be a horrible pain in the ass...

Can cookies bet set up to run without using php? I am only 30 pages away on my site from going from page.htm to page.php...

but in the meantime, I would like this cookie thing to be in the .htm pages.

If it is not possible, I will put it off until I get to the php pages, but if it is possible that would be awesome.

I just don't know how to set my site up to give cookies. I sort of understand how they work. I know what they do, how they are written (kind of) etc. Like I know you have to have them before the <HTML> with no white space, etc.. but I can't seem to get them to execute.

Thanks again

10-19-2005, 06:15 PM
You can just rename the .html pages to .php and use PHP.
Apart from that... yes, you can read and write to document.cookie in Javascript just as any other variable.