请问:无法获取Cookie…彻底晕了,救命

请教:无法获取Cookie……彻底晕了,救命。
现有html代码如下:
<html   xmlns= "http://www.w3.org/1999/xhtml "   >
<head>
        <title> 无标题页 </title>
        <script   language= "javascript "   type= "text/javascript ">
                function   AddCookie()
                {
                        var   dateobj=new   Date();
                        dateobj.setTime(dateobj.getTime()+1000*60);
                        window.self.document.cookie= "TestName1=Value1;expires= "+dateobj.getTime();
                        window.self.alert(window.self.document.cookie);
                }
                function   ShowCookie()
                {
                        window.self.alert(window.self.document.cookie);
                }                
        </script>
</head>
<body>
<div>
                <input   id= "Button1 "   type= "button "   value= "添加并显示Cookie "   onclick= "AddCookie() "   />
                <input   id= "Button2 "   type= "button "   value= "显示Cookie "   onclick= "ShowCookie() "   />
</div>
</body>
</html>

当点击Button1时,弹出提示框的内容是: "TestName1=Value1 "
当点击Button2时,弹出提示框的内容是: " "
我用的操作系统是XP,所以检查路径:C:\Documents   and   Settings\MyUserName\Cookies,发现对应的Cookie文件已经被建立,Cookie_Name和Cookie_Value已经被写了进去。

请问,为什么不在一个Function内,Cookie就无法获取了呢?
Cookie本身是属于一个站点的,和函数有什么关系呢?

------解决方案--------------------
window.self.document.cookie= "TestName1=Value1;expires= "+dateobj.toGMTString();