View Full Version : cookies are driving me crazy!

Jun 19th, 2006, 11:59 PM
ahhhhh i have spent the last few hours just trying to find a simple tutorial!

im ok with some basic Javascript

all i was is a simple cookie script!

on one page called set.html
- i want to create a cookie with a specific name (uh first_cookieA i will call it)
- it needs to have a code word can be anything (lets say orange)

second page called read.html
- needs to read the first_cookieA and extract the data (orange) save as a variable

so basically when read.html is opened i want it type a message when the cookie is present and a different message when it is not present

help please!!! thanks

Jun 20th, 2006, 12:21 AM
I use the scripts found here. http://www.quirksmode.org/js/cookies.html
Some might think its a bit overkill but I find it to be easy to work with.

Jun 20th, 2006, 01:54 PM
ok i design this little script trying to get my head round cookies

but get an error when the READ is clicked 'error on page is displayed in internet explorer

<script language="javascript">
function creater()
document.cookie = 'ppkcookie1=another test';
function reader()
var x = readCookie('ppkcookie1');
alert("done reading");
alert("cookie reads " + x);
hello world!
<a onClick="javascript:creater()">create</a>
<br><br><a onClick="javascript:reader()">read</a>

can any one help or fix the problem?

Jun 20th, 2006, 01:56 PM
ah just noticed the readCookie is a preset function!


Jun 20th, 2006, 04:57 PM
All sorted script is working when loaded from my pc however when loaded to my server (tripod) it doesnt seem to work!
does tripod not allow cookies?

Jun 20th, 2006, 05:12 PM
Pretty sure they do. Do you have a link to the site?

Jun 20th, 2006, 07:22 PM


i have counters on most pages but wanted an admin setting so that the counters would not regonise my visits! i was going to use cookies to recognise the admin!

i set up a test page http://distouk.tripod.com/tester.html

but you need to create the cookie on http://distouk.tripod.com/script2.html by writing go (as the admin login) in the text box and clicking 'create cookie'

if your logged in as the admin the counter at the bottom shouldnt be shown and the message "you are logged in as ADMIN no counter!" should be displayed!
every time i try the script the counter is always displayed.

uh hope that makes sense ask me if your unsure about anything...

oh and let me know what you think of the site!


i was just testing the links on this post to make sure they were correct and the script works perfectly now, thanks for your help, your welcome to have a look at the rest of the site and my script to see how it worked though!!! some comments would be great!