View Full Version : if statement for reading cookies

03-23-2005, 12:32 PM
I am trying to come up with a kind of IF statement for reading cookies however it's not working for me. Heres what I got so far:

<script language="JavaScript" type="text/javascript">

function createLuckyCookie() {
when= new Date()
document.cookie = "luckycookie=lucky;expires="+expires+";path=/"

function getCookie(luckycookie) {
var prefix = luckycookie + "="
var cookieStartIndex = document.cookie.indexOf(prefix)
if (cookieStartIndex == -1)
return null
var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
if (cookieEndIndex == -1)
cookieEndIndex = document.cookie.length
return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))

function checkLuckyCookie() {
if (document.cookie.= "") {
return false;

else {
return false;


<a href="#" onclick="checkLuckyCookie();return false">
<IMG SRC="00.gif" NAME="luckyimage" ID="g0" ALT="" BORDER="0"></A>

I am trying to get this script so basicaly say: "If cookie, do this. If no cookie, do this." It's so simple yet it's killing me I can't do it. Any comments/suggestions would greatly be apreciated. Thanks.

~Isaac Lloyd~

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum