This is a reiteration of the enabling cookies posted that somebody wanted me to resubmit for clarity
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/7762369/how-to-enable-cookies">How to enable cookies</a>  </p>
</blockquote>



<p>The <code>readCookie</code> is right under the <code>greetUser</code> function. I put in the <code>writeCookie</code> function but it causes the <code>alert</code> boxes not to show. So I commented it out. </p>

<p>This is about the cookies not working. I'm suppose to sort the username it a variable so that <code>iRock</code> will remember the name and use it in the prompt. </p>

<p>It seems like the last part of the code works because I get the <code>alert</code> boxes, but I don't get the first and second alert boxes. The page is suppose to open in an alert box saying, "Hello, I am a pet rock." but it doesn't.</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org   /TR/xhtml1    /DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
&lt;title&gt;iRock - The Virtual Pet Rock&lt;/title&gt;
&lt;link href="donut_stylesheet/donut.css" rel="stylesheet" type="text/css" /&gt;
&lt;script type ="text/javascript"&gt;
var userName;

function resizeRock(){
    document.getElementById("rockImg").style.height = (document.body.clientHeight - 100) * 0.9;
}

function greetUser(){
    userName = readCookie("rock_username");
    if(userName)
        alert("Hello " + userName + ", I missed you.");
    else 
        alert("Hello, I am your pet rock");
}

function touchRock(){
    if(userName)
        alert("I like attention," + userName + ". Thank you.");
}

userName = prompt("What is your name?", "Enter name here.");
if(userName) 
    alert("It is good to meet you, " + userName + ".");
    //writeCookie(irock_username", userName, 1 * 365);

document.getElementById("rockImg").src = "rock_happy.png";
setTimeout("document.getElementById(('rockImg').src = 'images/rock.png';", 5 * 60 * 1000);
&lt;/script&gt;
&lt;/head&gt;
&lt;body onload="resizeRock(); greetUser(); onResize="resizeRock();"&gt;
 &lt;img id="rockImg" src="images/rock.png" alt="iRock" style="cursor:pointer"    onClick="touchRock();" /&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
