У меня в Хроме 11.0.696.71 всегда null...
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<style type="text/css">
</style>
<script type="text/javascript">
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "")
if ((name + "=" + escape(value)).length <= 4000)
document.cookie = curCookie
else if (confirm("Cookie РїС_РчР_С<С_Р°РчС' 4KB Рё Р+С_Р_РчС' Р_С<С_РчР·Р°Р_ !"))
document.cookie = curCookie
}
function getCookie(name) {
var prefix = name + "="
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))
}
</script>
</head>
<body>
<input type='text' id='test' />
<input type='button' value='Set' onclick='setCookie("Val",document.getElementById("test").value);alert("Ok")' />
<input type='button' value='Get' onclick='alert(getCookie("Val"))' />
</body>
</html>
В ИЕ7, ФФ, Опере все работает...