Im pulling my hair out here. I started with cookies today. I write 2 cookies which I need to access from a different window later. In the one page I have the following script:
I call the function "opencomment(title,id)" in the page, and it executes correctly.
Code: Select all
<SCRIPT TYPE="text/javascript">
<!--
function DT_setcookie(name, value)
{
document.cookie = name+"="+escape(value);
return document.cookie;
}
function opencomment(title,id)
{
var vId = id;
var vTitle = title;
DT_setcookie("test_title",vTitle);
DT_setcookie("test_id",vId);
}
-->
</SCRIPT>
Code: Select all
<SCRIPT TYPE="text/javascript">
<!--
function getCookie(name)
{
var startpos = document.cookie.indexOf(name)+name.length+1;
var endpos = document.cookie.indexOf(";",startpos)-1;
if (endpos == -2) endpos = document.cookie.length;
var result = unescape(document.cookie.substring(startpos,endpos));
return result;
}
function readcookies()
{
var vId = getCookie("test_id");
var vTitle = getCookie("test_title");
}
-->
</SCRIPT>
Code: Select all
test_title=cookietitle; test_id=5; __utma=193928944.2115910489.1268903752.1271409901.1272881314.3; __utmz=193928944.1268903752.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none)
When I read the cookie with the getCookie function, I get this result:
Code: Select all
193928944.2115910489.1268903752.1271409901.1272881314.
and
928944.2115910489.1268903752.1271409901.1272881314.