multiple cookie problem
Moderator: General Moderators
-
Ok, here are the files again, reduced to the max. The files will create output five meta-refreshes, the sixth will fail (javascript error: each_cookie undefinde), because cookie2 is not readable.
Does this occur on your browser also? how do the cookies look like after 5 or 6 refresh?
thx, djot
-
chat.php
chat.js
chat.js
chat.js
chat.js
chat.js
chat.js
chat.js
chat.js
chat.js
Ok, here are the files again, reduced to the max. The files will create output five meta-refreshes, the sixth will fail (javascript error: each_cookie undefinde), because cookie2 is not readable.
Does this occur on your browser also? how do the cookies look like after 5 or 6 refresh?
thx, djot
-
chat.php
Code: Select all
<?php
$id = $_GETї'id'];
$action = $_GETї'action'];
$random_data_amount = 50;
if (empty($action))
{
$action = "frame";
}
if ($action == "msg")
{
for($i=1; $i<=$random_data_amount; $i++)
{
$line = $id + $i;
$msg .= "user".$line."message".$line."";
}
echo "newmessages = "".$msg."";";
}
if ($action == "frame")
{
$js_messageid = "
<script language="JavaScript">
<!--
messageid = "".$id."";
-->
</script>
";
} // if ($action == "frame")
if ($action == "frame")
{
$line = $id + $random_data_amount;
$chat ="
<html>
<head>
<meta http-equiv="refresh" content="4; url=./chat.php?action=frame&id=".$line."">
".$js_messageid."
<script language="JavaScript" src="./chat.php?action=msg&id=".$id.""></script>
<script language="JavaScript" src="./chat.js"></script>
</head>
<body>
<script language="JavaScript">
<!--
document.write(chat);
-->
</script>
</body>
</html>
";
echo $chat;
} // if ($action == "frame")
?>Code: Select all
var config_cookies_datasize = 3999;
var config_cookies_amount = 10;
var config_cookies_names = ["a","b","c","d","e","f","g","h","i","j"];
function SetCookies(cookiedata)
{
if (messageid == 200) { alert("This is the last time, all cookies are set correctly. Next time cookies are get, the second cookie is undefinde.\n\function SetCookies(" + cookiedata+ ")"); }
var start = 0;
var expiration_date = new Date("January 1, 3000");
expiration_date = expiration_date.toGMTString();
var now = new Date();
now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * 365)
for (i = 0; i < config_cookies_amount; i++)
{
cookiepart = cookiedata.substr(start,config_cookies_datasize);
cookiepart = escape(cookiepart);
cookiestring = "chatkeks" + config_cookies_namesїi] + "=" + cookiepart + ";expires=" + now;
if (messageid == 200)
{
//alert("SetCookies (i: " + i + "): MessagesID= " + messageid + "\ncookiestring=\n" + cookiestring);
}
document.cookie = cookiestring;
start = start + config_cookies_datasize;
}
} // function SetCookies()
function GetCookies()
{
if (document.cookie && document.cookie != "")
{
var whole_cookie = unescape(document.cookie);
alert("MessagesID= " + messageid + "\nwhole_cookie=\n" + whole_cookie);
var each_cookie = whole_cookie.split(";");
var chatkeks_data = ї];
//sorting loop
for (i=0; i < config_cookies_amount; i++)
{
if (each_cookieїi].indexOf("chatkeksa") > -1) { chatkeks_dataї'a'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksb") > -1) { chatkeks_dataї'b'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksc") > -1) { chatkeks_dataї'c'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksd") > -1) { chatkeks_dataї'd'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkekse") > -1) { chatkeks_dataї'e'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksf") > -1) { chatkeks_dataї'f'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksg") > -1) { chatkeks_dataї'g'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksh") > -1) { chatkeks_dataї'h'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksi") > -1) { chatkeks_dataї'i'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksj") > -1) { chatkeks_dataї'j'] = each_cookieїi]; }
} // for
//splitting data and assigning final display variable
var chatkeks_split = ї];
var chatkeks = ї];
for (i=0; i <e files again, reduced to the max. The files will create output five meta-refreshes, the sixth will fail (javascript error: each_cookie[i] undefinde), because cookie2 is not readable.
Does this occur on your browser also? how do the cookies look like after 5 or 6 refresh?
thx, djot
-
chat.phpCode: Select all
<?php
$id = $_GET['id'];
$action = $_GET['action'];
$random_data_amount = 50;
if (empty($action))
{
$action = "frame";
}
if ($action == "msg")
{
for($i=1; $i<=$random_data_amount; $i++)
{
$line = $id + $i;
$msg .= "user".$line."message".$line."";
}
echo "newmessages = "".$msg."";";
}
if ($action == "frame")
{
$js_messageid = "
<script language="JavaScript">
<!--
messageid = "".$id."";
-->
</script>
";
} // if ($action == "frame")
if ($action == "frame")
{
$line = $id + $random_data_amount;
$chat ="
<html>
<head>
<meta http-equiv="refresh" content="4; url=./chat.php?action=frame&id=".$line."">
".$js_messageid."
<script language="JavaScript" src="./chat.php?action=msg&id=".$id.""></script>
<script language="JavaScript" src="./chat.js"></script>
</head>
<body>
<script language="JavaScript">
<!--
document.write(chat);
-->
</script>
</body>
</html>
";
echo $chat;
} // if ($action == "frame")
?>Code: Select all
var config_cookies_datasize = 3999;
var config_cookies_amount = 10;
var config_cookies_names = ї"a","b","c","d","e","f","g","h","i","j"];
function SetCookies(cookiedata)
{
if (messageid == 200) { alert("This is the last time, all cookies are set correctly. Next time cookies are get, the second cookie is undefinde.\n\function SetCookies(" + cookiedata+ ")"); }
var start = 0;
var expiration_date = new Date("January 1, 3000");
expiration_date = expiration_date.toGMTString();
var now = new Date();
now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * 365)
for (i = 0; i < config_cookies_amount; i++)
{
cookiepart = cookiedata.substr(start,config_cookies_datasize);
cookiepart = escape(cookiepart);
cookiestring = "chatkeks" + config_cookies_namesїi] + "=" + cookiepart + ";expires=" + now;
if (messageid == 200)
{
//alert("SetCookies (i: " + i + "): MessagesID= " + messageid + "\ncookiestring=\n" + cookiestring);
}
document.cookie = cookiestring;
start = start + config_cookies_datasize;
}
} // function SetCookies()
function GetCookies()
{
if (document.cookie && document.cookie != "")
{
var whole_cookie = unescape(document.cookie);
alert("MessagesID= " + messageid + "\nwhole_cookie=\n" + whole_cookie);
var each_cookie = whole_cookie.split(";");
var chatkeks_data = ї];
//sorting loop
for (i=0; i < config_cookies_amount; i++)
{
if (each_cookieїi].indexOf("chatkeksa") > -1) { chatkeks_dataї'a'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksb") > -1) { chatkeks_dataї'b'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksc") > -1) { chatkeks_dataї'c'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksd") > -1) { chatkeks_dataї'd'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkekse") > -1) { chatkeks_dataї'e'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksf") > -1) { chatkeks_dataї'f'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksg") > -1) { chatkeks_dataї'g'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksh") > -1) { chatkeks_dataї'h'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksi") > -1) { chatkeks_dataї'i'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksj") > -1) { chatkeks_dataї'j'] = each_cookieїi]; }
} // for
//splitting data and assigning final display variable
var chatkeks_split = ї];
var chatkeks = ї];
for (i=0; i < config_cookies_amount; i++)
{
cookieindex = config_cookies_namesїi];
chatkeks_splitїcookieindex] = chatkeks_dataїcookieindex].split("=");
if ( typeof(chatkeks_splitїcookieindex]ї1]) != "undefined" && chatkeks_splitїcookieindex]ї1] != "")
{
chatkeksїcookieindex] = chatkeks_splitїcookieindex]ї1];
}
}
var cookiedata = "";
for (i=0; i < config_cookies_amount; i++)
{
cookieindex = config_cookies_namesїi];
if ( typeof(chatkeksїcookieindex]) != "undefined" && chatkeksїcookieindex] != "")
{
cookiedata += chatkeksїcookieindex];
}
}
oldmessages = cookiedata;
} // if (document.cookie && document.cookie != "")
} // function GetCookies()
function JsChat()
{
var cookiedata = "";
var messages = "";
GetCookies();
if ( typeof(oldmessages) != "undefined" )
{
messages += oldmessages;
cookiedata += oldmessages;
}
if ( typeof(newmessages) != "undefined" )
{
messages += newmessages;
cookiedata += newmessages;
}
if (messageid == 250) { alert("vor SetCookies(" + cookiedata + ");"); }
SetCookies(cookiedata);
return message files again, reduced to the max. The files will create output five meta-refreshes, the sixth will fail (javascript error: each_cookie[i] undefinde), because cookie2 is not readable.
Does this occur on your browser also? how do the cookies look like after 5 or 6 refresh?
thx, djot
-
chat.phpCode: Select all
<?php
$id = $_GET['id'];
$action = $_GET['action'];
$random_data_amount = 50;
if (empty($action))
{
$action = "frame";
}
if ($action == "msg")
{
for($i=1; $i<=$random_data_amount; $i++)
{
$line = $id + $i;
$msg .= "user".$line."message".$line."";
}
echo "newmessages = "".$msg."";";
}
if ($action == "frame")
{
$js_messageid = "
<script language="JavaScript">
<!--
messageid = "".$id."";
-->
</script>
";
} // if ($action == "frame")
if ($action == "frame")
{
$line = $id + $random_data_amount;
$chat ="
<html>
<head>
<meta http-equiv="refresh" content="4; url=./chat.php?action=frame&id=".$line."">
".$js_messageid."
<script language="JavaScript" src="./chat.php?action=msg&id=".$id.""></script>
<script language="JavaScript" src="./chat.js"></script>
</head>
<body>
<script language="JavaScript">
<!--
document.write(chat);
-->
</script>
</body>
</html>
";
echo $chat;
} // if ($action == "frame")
?>Code: Select all
var config_cookies_datasize = 3999;
var config_cookies_amount = 10;
var config_cookies_names = ї"a","b","c","d","e","f","g","h","i","j"];
function SetCookies(cookiedata)
{
if (messageid == 200) { alert("This is the last time, all cookies are set correctly. Next time cookies are get, the second cookie is undefinde.\n\function SetCookies(" + cookiedata+ ")"); }
var start = 0;
var expiration_date = new Date("January 1, 3000");
expiration_date = expiration_date.toGMTString();
var now = new Date();
now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * 365)
for (i = 0; i < config_cookies_amount; i++)
{
cookiepart = cookiedata.substr(start,config_cookies_datasize);
cookiepart = escape(cookiepart);
cookiestring = "chatkeks" + config_cookies_namesїi] + "=" + cookiepart + ";expires=" + now;
if (messageid == 200)
{
//alert("SetCookies (i: " + i + "): MessagesID= " + messageid + "\ncookiestring=\n" + cookiestring);
}
document.cookie = cookiestring;
start = start + config_cookies_datasize;
}
} // function SetCookies()
function GetCookies()
{
if (document.cookie && document.cookie != "")
{
var whole_cookie = unescape(document.cookie);
alert("MessagesID= " + messageid + "\nwhole_cookie=\n" + whole_cookie);
var each_cookie = whole_cookie.split(";");
var chatkeks_data = ї];
//sorting loop
for (i=0; i < config_cookies_amount; i++)
{
if (each_cookieїi].indexOf("chatkeksa") > -1) { chatkeks_dataї'a'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksb") > -1) { chatkeks_dataї'b'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksc") > -1) { chatkeks_dataї'c'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksd") > -1) { chatkeks_dataї'd'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkekse") > -1) { chatkeks_dataї'e'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksf") > -1) { chatkeks_dataї'f'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksg") > -1) { chatkeks_dataї'g'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksh") > -1) { chatkeks_dataї'h'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksi") > -1) { chatkeks_dataї'i'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksj") > -1) { chatkeks_dataї'j'] = each_cookieїi]; }
} // for
//splitting data and assigning final display variable
var chatkeks_split = ї];
var chatkeks = ї];
for (i=0; i < config_cookies_amount; i++)
{
cookieindex = config_cookies_namesїi];
chatkeks_splitїcookieindex] = chatkeks_dataїcookieindex].split("=");
if ( typeof(chatkeks_splitїcookieindex]ї1]) != "undefined" && chatkeks_splitїcookieindex]ї1] != "")
{
chatkeksїcookieindex] = chatkeks_splitїcookieindex]ї1];
}
}
var cookiedata = "";
for (i=0; i < config_cookies_amount; i++)
{
cookieindex = config_cookies_namesїi];
if ( typeof(chatkeksїcookieindex]) != "undefined" && chatkeksїcookieindex] != "")
{
cookiedata += chatkeksїcookieindex];
}
}
oldmessages = cookiedata;
} // if (document.cookie && document.cookie != "")
} // function GetCookies()
function JsChat()
{
var cookiedata = "";
var messages = "";
GetCookies();
if ( typeof(oldmessages) != "undefined" )
{
messages += oldmessages;
cookiedata += oldmessages;
}
if ( typeof(newmessages) != "undefined" )
{
messages += newmessages;
cookiedata += newmessages;
}
if (messageid == 250) { alert("vor SetCookies(" + cookiedata + ");"); }
SetCookies(cooke files again, reduced to the max. The files will create output five meta-refreshes, the sixth will fail (javascript error: each_cookie[i] undefinde), because cookie2 is not readable.
Does this occur on your browser also? how do the cookies look like after 5 or 6 refresh?
thx, djot
-
chat.phpCode: Select all
<?php
$id = $_GET['id'];
$action = $_GET['action'];
$random_data_amount = 50;
if (empty($action))
{
$action = "frame";
}
if ($action == "msg")
{
for($i=1; $i<=$random_data_amount; $i++)
{
$line = $id + $i;
$msg .= "user".$line."message".$line."";
}
echo "newmessages = "".$msg."";";
}
if ($action == "frame")
{
$js_messageid = "
<script language="JavaScript">
<!--
messageid = "".$id."";
-->
</script>
";
} // if ($action == "frame")
if ($action == "frame")
{
$line = $id + $random_data_amount;
$chat ="
<html>
<head>
<meta http-equiv="refresh" content="4; url=./chat.php?action=frame&id=".$line."">
".$js_messageid."
<script language="JavaScript" src="./chat.php?action=msg&id=".$id.""></script>
<script language="JavaScript" src="./chat.js"></script>
</head>
<body>
<script language="JavaScript">
<!--
document.write(chat);
-->
</script>
</body>
</html>
";
echo $chat;
} // if ($action == "frame")
?>Code: Select all
var config_cookies_datasize = 3999;
var config_cookies_amount = 10;
var config_cookies_names = ї"a","b","c","d","e","f","g","h","i","j"];
function SetCookies(cookiedata)
{
if (messageid == 200) { alert("This is the last time, all cookies are set correctly. Next time cookies are get, the second cookie is undefinde.\n\function SetCookies(" + cookiedata+ ")"); }
var start = 0;
var expiration_date = new Date("January 1, 3000");
expiration_date = expiration_date.toGMTString();
var now = new Date();
now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * 365)
for (i = 0; i < config_cookies_amount; i++)
{
cookiepart = cookiedata.substr(start,config_cookies_datasize);
cookiepart = escape(cookiepart);
cookiestring = "chatkeks" + config_cookies_namesїi] + "=" + cookiepart + ";expires=" + now;
if (messageid == 200)
{
//alert("SetCookies (i: " + i + "): MessagesID= " + messageid + "\ncookiestring=\n" + cookiestring);
}
document.cookie = cookiestring;
start = start + config_cookies_datasize;
}
} // function SetCookies()
function GetCookies()
{
if (document.cookie && document.cookie != "")
{
var whole_cookie = unescape(document.cookie);
alert("MessagesID= " + messageid + "\nwhole_cookie=\n" + whole_cookie);
var each_cookie = whole_cookie.split(";");
var chatkeks_data = ї];
//sorting loop
for (i=0; i < config_cookies_amount; i++)
{
if (each_cookieїi].indexOf("chatkeksa") > -1) { chatkeks_dataї'a'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksb") > -1) { chatkeks_dataї'b'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksc") > -1) { chatkeks_dataї'c'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksd") > -1) { chatkeks_dataї'd'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkekse") > -1) { chatkeks_dataї'e'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksf") > -1) { chatkeks_dataї'f'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksg") > -1) { chatkeks_dataї'g'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksh") > -1) { chatkeks_dataї'h'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksi") > -1) { chatkeks_dataї'i'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksj") > -1) { chatkeks_dataї'j'] = each_cookieїi]; }
} // for
//splitting data and assigning final display variable
var chatkeks_split = ї];
var chatkeks = ї];
for (i=0; i < config_cookies_amount; i++)
{
cookieindex = config_cookies_namesїi];
chatkeks_splitїcookieindex] = chatkeks_dataїcookieindex].split("=");
if ( typeof(chatkeks_splitїcookieindex]ї1]) != "undefined" && chatkeks_splitїcookieindex]ї1] != "")
{
chatkeksїcookieindex] = chatkeks_splitїcookieindex]ї1];
}
}
var cookiedata = "";
for (i=0; i < config_cookies_amount; i++)
{
cookieindex = config_cookies_namesїi];
if ( typeof(chatkeksїcookieindex]) != "undefined" && chatkeksїcookieindex] != "")
{
cookiedata += chatkeksїcookieindex];
}
}
oldmessages = cookiedata;
} // if (document.cookie && document.cookie != "")
} // function GetCookies()
function JsChat()
{
var cookiedata = "";
var messages = "";
GetCookies();
if ( typeof(oldmessages) != "undefined" )
{
messages += oldmessages;
cookiedata += oldmessages;
}
if ( typeof(newmessages) != "undefined" )
{
messages += newmessages;
cookiedata += newmessages;
}
if (messageid == 250) { alert("vor SetCookies(" + cookiedata + ");"); }
SetCookies(cookiedata);
return messages;
}
ve files again, reduced to the max. The files will create output five meta-refreshes, the sixth will fail (javascript error: each_cookie[i] undefinde), because cookie2 is not readable.
Does this occur on your browser also? how do the cookies look like after 5 or 6 refresh?
thx, djot
-
chat.phpCode: Select all
<?php
$id = $_GET['id'];
$action = $_GET['action'];
$random_data_amount = 50;
if (empty($action))
{
$action = "frame";
}
if ($action == "msg")
{
for($i=1; $i<=$random_data_amount; $i++)
{
$line = $id + $i;
$msg .= "user".$line."message".$line."";
}
echo "newmessages = "".$msg."";";
}
if ($action == "frame")
{
$js_messageid = "
<script language="JavaScript">
<!--
messageid = "".$id."";
-->
</script>
";
} // if ($action == "frame")
if ($action == "frame")
{
$line = $id + $random_data_amount;
$chat ="
<html>
<head>
<meta http-equiv="refresh" content="4; url=./chat.php?action=frame&id=".$line."">
".$js_messageid."
<script language="JavaScript" src="./chat.php?action=msg&id=".$id.""></script>
<script language="JavaScript" src="./chat.js"></script>
</head>
<body>
<script language="JavaScript">
<!--
document.write(chat);
-->
</script>
</body>
</html>
";
echo $chat;
} // if ($action == "frame")
?>Code: Select all
var config_cookies_datasize = 3999;
var config_cookies_amount = 10;
var config_cookies_names = ї"a","b","c","d","e","f","g","h","i","j"];
function SetCookies(cookiedata)
{
if (messageid == 200) { alert("This is the last time, all cookies are set correctly. Next time cookies are get, the second cookie is undefinde.\n\function SetCookies(" + cookiedata+ ")"); }
var start = 0;
var expiration_date = new Date("January 1, 3000");
expiration_date = expiration_date.toGMTString();
var now = new Date();
now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * 365)
for (i = 0; i < config_cookies_amount; i++)
{
cookiepart = cookiedata.substr(start,config_cookies_datasize);
cookiepart = escape(cookiepart);
cookiestring = "chatkeks" + config_cookies_namesїi] + "=" + cookiepart + ";expires=" + now;
if (messageid == 200)
{
//alert("SetCookies (i: " + i + "): MessagesID= " + messageid + "\ncookiestring=\n" + cookiestring);
}
document.cookie = cookiestring;
start = start + config_cookies_datasize;
}
} // function SetCookies()
function GetCookies()
{
if (document.cookie && document.cookie != "")
{
var whole_cookie = unescape(document.cookie);
alert("MessagesID= " + messageid + "\nwhole_cookie=\n" + whole_cookie);
var each_cookie = whole_cookie.split(";");
var chatkeks_data = ї];
//sorting loop
for (i=0; i < config_cookies_amount; i++)
{
if (each_cookieїi].indexOf("chatkeksa") > -1) { chatkeks_dataї'a'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksb") > -1) { chatkeks_dataї'b'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksc") > -1) { chatkeks_dataї'c'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksd") > -1) { chatkeks_dataї'd'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkekse") > -1) { chatkeks_dataї'e'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksf") > -1) { chatkeks_dataї'f'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksg") > -1) { chatkeks_dataї'g'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksh") > -1) { chatkeks_dataї'h'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksi") > -1) { chatkeks_dataї'i'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksj") > -1) { chatkeks_dataї'j'] = each_cookieїi]; }
} // for
//splitting data and assigning final display variable
var chatkeks_split = ї];
var chatkeks = ї];
for (i=0; i < config_cookies_amount; i++)
{
cookieindex = config_cookies_namesїi];
chatkeks_splitїcookieindex] = chatkeks_dataїcookieindex].split("=");
if ( typeof(chatkeks_splitїcookieindex]ї1]) != "undefined" && chatkeks_splitїcookieindex]ї1] != "")
{
chatkeksїcookieindex] = chatkeks_splitїcookieindex]ї1];
}
}
var cookiedata = "";
for (i=0; i < config_cookies_amount; i++)
{
cookieindex = config_cookies_namesїi];
if ( typeof(chatkeksїcookieindex]) != "undefined" && chatkeksїcookieindex] != "")
{
cookiedata += chatkeksїcookieindex];
}
}
oldmessages = cookiedata;
} // if (document.cookie && document.cookie != "")
} // function GetCookies()
function JsChat()
{
var cookiedata = "";
var messages = "";
GetCookies();
if ( typeof(oldmessages) != "undefined" )
{
messages += oldmessages;
cookiedata += oldmessages;
}
if ( typeof(newmessages) != "undefined" )
{
messages += newmessages;
cookiedata += newmessages;
}
if (messageid == 250) { alert("vor SetCookies(" + cookiedata + ");"); }
SetCookies(cookiedata);
return messages;
&e files again, reduced to the max. The files will create output five meta-refreshes, the sixth will fail (javascript error: each_cookie[i] undefinde), because cookie2 is not readable.
Does this occur on your browser also? how do the cookies look like after 5 or 6 refresh?
thx, djot
-
chat.phpCode: Select all
<?php
$id = $_GET['id'];
$action = $_GET['action'];
$random_data_amount = 50;
if (empty($action))
{
$action = "frame";
}
if ($action == "msg")
{
for($i=1; $i<=$random_data_amount; $i++)
{
$line = $id + $i;
$msg .= "user".$line."message".$line."";
}
echo "newmessages = "".$msg."";";
}
if ($action == "frame")
{
$js_messageid = "
<script language="JavaScript">
<!--
messageid = "".$id."";
-->
</script>
";
} // if ($action == "frame")
if ($action == "frame")
{
$line = $id + $random_data_amount;
$chat ="
<html>
<head>
<meta http-equiv="refresh" content="4; url=./chat.php?action=frame&id=".$line."">
".$js_messageid."
<script language="JavaScript" src="./chat.php?action=msg&id=".$id.""></script>
<script language="JavaScript" src="./chat.js"></script>
</head>
<body>
<script language="JavaScript">
<!--
document.write(chat);
-->
</script>
</body>
</html>
";
echo $chat;
} // if ($action == "frame")
?>Code: Select all
var config_cookies_datasize = 3999;
var config_cookies_amount = 10;
var config_cookies_names = ї"a","b","c","d","e","f","g","h","i","j"];
function SetCookies(cookiedata)
{
if (messageid == 200) { alert("This is the last time, all cookies are set correctly. Next time cookies are get, the second cookie is undefinde.\n\function SetCookies(" + cookiedata+ ")"); }
var start = 0;
var expiration_date = new Date("January 1, 3000");
expiration_date = expiration_date.toGMTString();
var now = new Date();
now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * 365)
for (i = 0; i < config_cookies_amount; i++)
{
cookiepart = cookiedata.substr(start,config_cookies_datasize);
cookiepart = escape(cookiepart);
cookiestring = "chatkeks" + config_cookies_namesїi] + "=" + cookiepart + ";expires=" + now;
if (messageid == 200)
{
//alert("SetCookies (i: " + i + "): MessagesID= " + messageid + "\ncookiestring=\n" + cookiestring);
}
document.cookie = cookiestring;
start = start + config_cookies_datasize;
}
} // function SetCookies()
function GetCookies()
{
if (document.cookie && document.cookie != "")
{
var whole_cookie = unescape(document.cookie);
alert("MessagesID= " + messageid + "\nwhole_cookie=\n" + whole_cookie);
var each_cookie = whole_cookie.split(";");
var chatkeks_data = ї];
//sorting loop
for (i=0; i < config_cookies_amount; i++)
{
if (each_cookieїi].indexOf("chatkeksa") > -1) { chatkeks_dataї'a'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksb") > -1) { chatkeks_dataї'b'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksc") > -1) { chatkeks_dataї'c'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksd") > -1) { chatkeks_dataї'd'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkekse") > -1) { chatkeks_dataї'e'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksf") > -1) { chatkeks_dataї'f'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksg") > -1) { chatkeks_dataї'g'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksh") > -1) { chatkeks_dataї'h'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksi") > -1) { chatkeks_dataї'i'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksj") > -1) { chatkeks_dataї'j'] = each_cookieїi]; }
} // for
//splitting data and assigning final display variable
var chatkeks_split = ї];
var chatkeks = ї];
for (i=0; i < config_cookies_amount; i++)
{
cookieindex = config_cookies_namesїi];
chatkeks_splitїcookieindex] = chatkeks_dataїcookieindex].split("=");
if ( typeof(chatkeks_splitїcookieindex]ї1]) != "undefined" && chatkeks_splitїcookieindex]ї1] != "")
{
chatkeksїcookieindex] = chatkeks_splitїcookieindex]ї1];
}
}
var cookiedata = "";
for (i=0; i < config_cookies_amount; i++)
{
cookieindex = config_cookies_namesїi];
if ( typeof(chatkeksїcookieindex]) != "undefined" && chatkeksїcookieindex] != "")
{
cookiedata += chatkeksїcookieindex];
}
}
oldmessages = cookiedata;
} // if (document.cookie && document.cookie != "")
} // function GetCookies()
function JsChat()
{
var cookiedata = "";
var messages = "";
GetCookies();
if ( typeof(oldmessages) != "undefined" )
{
messages += oldmessages;
cookiedata += oldmessages;
}
if ( typeof(newmessages) != "undefined" )
{
messages += newmessages;
cookiedata += newmessages;
}
if (messageid == 250) { alert("vor SetCookies(" + cookiedata + ");"); }
SetCookies(cookiedata);
return messages;
}
var chat = ""ax. The files will create output five meta-refreshes, the sixth will fail (javascript error: each_cookie[i] undefinde), because cookie2 is not readable.
Does this occur on your browser also? how do the cookies look like after 5 or 6 refresh?
thx, djot
-
chat.phpCode: Select all
<?php
$id = $_GET['id'];
$action = $_GET['action'];
$random_data_amount = 50;
if (empty($action))
{
$action = "frame";
}
if ($action == "msg")
{
for($i=1; $i<=$random_data_amount; $i++)
{
$line = $id + $i;
$msg .= "user".$line."message".$line."";
}
echo "newmessages = "".$msg."";";
}
if ($action == "frame")
{
$js_messageid = "
<script language="JavaScript">
<!--
messageid = "".$id."";
-->
</script>
";
} // if ($action == "frame")
if ($action == "frame")
{
$line = $id + $random_data_amount;
$chat ="
<html>
<head>
<meta http-equiv="refresh" content="4; url=./chat.php?action=frame&id=".$line."">
".$js_messageid."
<script language="JavaScript" src="./chat.php?action=msg&id=".$id.""></script>
<script language="JavaScript" src="./chat.js"></script>
</head>
<body>
<script language="JavaScript">
<!--
document.write(chat);
-->
</script>
</body>
</html>
";
echo $chat;
} // if ($action == "frame")
?>Code: Select all
var config_cookies_datasize = 3999;
var config_cookies_amount = 10;
var config_cookies_names = ї"a","b","c","d","e","f","g","h","i","j"];
function SetCookies(cookiedata)
{
if (messageid == 200) { alert("This is the last time, all cookies are set correctly. Next time cookies are get, the second cookie is undefinde.\n\function SetCookies(" + cookiedata+ ")"); }
var start = 0;
var expiration_date = new Date("January 1, 3000");
expiration_date = expiration_date.toGMTString();
var now = new Date();
now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * 365)
for (i = 0; i < config_cookies_amount; i++)
{
cookiepart = cookiedata.substr(start,config_cookies_datasize);
cookiepart = escape(cookiepart);
cookiestring = "chatkeks" + config_cookies_namesїi] + "=" + cookiepart + ";expires=" + now;
if (messageid == 200)
{
//alert("SetCookies (i: " + i + "): MessagesID= " + messageid + "\ncookiestring=\n" + cookiestring);
}
document.cookie = cookiestring;
start = start + config_cookies_datasize;
}
} // function SetCookies()
function GetCookies()
{
if (document.cookie && document.cookie != "")
{
var whole_cookie = unescape(document.cookie);
alert("MessagesID= " + messageid + "\nwhole_cookie=\n" + whole_cookie);
var each_cookie = whole_cookie.split(";");
var chatkeks_data = ї];
//sorting loop
for (i=0; i < config_cookies_amount; i++)
{
if (each_cookieїi].indexOf("chatkeksa") > -1) { chatkeks_dataї'a'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksb") > -1) { chatkeks_dataї'b'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksc") > -1) { chatkeks_dataї'c'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksd") > -1) { chatkeks_dataї'd'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkekse") > -1) { chatkeks_dataї'e'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksf") > -1) { chatkeks_dataї'f'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksg") > -1) { chatkeks_dataї'g'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksh") > -1) { chatkeks_dataї'h'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksi") > -1) { chatkeks_dataї'i'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksj") > -1) { chatkeks_dataї'j'] = each_cookieїi]; }
} // for
//splitting data and assigning final display variable
var chatkeks_split = ї];
var chatkeks = ї];
for (i=0; i < config_cookies_amount; i++)
{
cookieindex = config_cookies_namesїi];
chatkeks_splitїcookieindex] = chatkeks_dataїcookieindex].split("=");
if ( typeof(chatkeks_splitїcookieindex]ї1]) != "undefined" && chatkeks_splitїcookieindex]ї1] != "")
{
chatkeksїcookieindex] = chatkeks_splitїcookieindex]ї1];
}
}
var cookiedata = "";
for (i=0; i < config_cookies_amount; i++)
{
cookieindex = config_cookies_namesїi];
if ( typeof(chatkeksїcookieindex]) != "undefined" && chatkeksїcookieindex] != "")
{
cookiedata += chatkeksїcookieindex];
}
}
oldmessages = cookiedata;
} // if (document.cookie && document.cookie != "")
} // function GetCookies()
function JsChat()
{
var cookiedata = "";
var messages = "";
GetCookies();
if ( typeof(oldmessages) != "undefined" )
{
messages += oldmessages;
cookiedata += oldmessages;
}
if ( typeof(newmessages) != "undefined" )
{
messages += newmessages;
cookiedata += newmessages;
}
if (messageid == 250) { alert("vor SetCookies(" + cookiedata + ");"); }
SetCookiesixth will fail (javascript error: each_cookie[i] undefinde), because cookie2 is not readable.
Does this occur on your browser also? how do the cookies look like after 5 or 6 refresh?
thx, djot
-
chat.phpCode: Select all
<?php
$id = $_GET['id'];
$action = $_GET['action'];
$random_data_amount = 50;
if (empty($action))
{
$action = "frame";
}
if ($action == "msg")
{
for($i=1; $i<=$random_data_amount; $i++)
{
$line = $id + $i;
$msg .= "user".$line."message".$line."";
}
echo "newmessages = "".$msg."";";
}
if ($action == "frame")
{
$js_messageid = "
<script language="JavaScript">
<!--
messageid = "".$id."";
-->
</script>
";
} // if ($action == "frame")
if ($action == "frame")
{
$line = $id + $random_data_amount;
$chat ="
<html>
<head>
<meta http-equiv="refresh" content="4; url=./chat.php?action=frame&id=".$line."">
".$js_messageid."
<script language="JavaScript" src="./chat.php?action=msg&id=".$id.""></script>
<script language="JavaScript" src="./chat.js"></script>
</head>
<body>
<script language="JavaScript">
<!--
document.write(chat);
-->
</script>
</body>
</html>
";
echo $chat;
} // if ($action == "frame")
?>Code: Select all
var config_cookies_datasize = 3999;
var config_cookies_amount = 10;
var config_cookies_names = ї"a","b","c","d","e","f","g","h","i","j"];
function SetCookies(cookiedata)
{
if (messageid == 200) { alert("This is the last time, all cookies are set correctly. Next time cookies are get, the second cookie is undefinde.\n\function SetCookies(" + cookiedata+ ")"); }
var start = 0;
var expiration_date = new Date("January 1, 3000");
expiration_date = expiration_date.toGMTString();
var now = new Date();
now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * 365)
for (i = 0; i < config_cookies_amount; i++)
{
cookiepart = cookiedata.substr(start,config_cookies_datasize);
cookiepart = escape(cookiepart);
cookiestring = "chatkeks" + config_cookies_namesїi] + "=" + cookiepart + ";expires=" + now;
if (messageid == 200)
{
//alert("SetCookies (i: " + i + "): MessagesID= " + messageid + "\ncookiestring=\n" + cookiestring);
}
document.cookie = cookiestring;
start = start + config_cookies_datasize;
}
} // function SetCookies()
function GetCookies()
{
if (document.cookie && document.cookie != "")
{
var whole_cookie = unescape(document.cookie);
alert("MessagesID= " + messageid + "\nwhole_cookie=\n" + whole_cookie);
var each_cookie = whole_cookie.split(";");
var chatkeks_data = ї];
//sorting loop
for (i=0; i < config_cookies_amount; i++)
{
if (each_cookieїi].indexOf("chatkeksa") > -1) { chatkeks_dataї'a'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksb") > -1) { chatkeks_dataї'b'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksc") > -1) { chatkeks_dataї'c'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksd") > -1) { chatkeks_dataї'd'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkekse") > -1) { chatkeks_dataї'e'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksf") > -1) { chatkeks_dataї'f'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksg") > -1) { chatkeks_dataї'g'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksh") > -1) { chatkeks_dataї'h'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksi") > -1) { chatkeks_dataї'i'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksj") > -1) { chatkeks_dataї'j'] = each_cookieїi]; }
} // for
//splitting data and assigning final display variable
var chatkeks_split = ї];
var chatkeks = ї];
for (i=0; i < config_cookies_amount; i++)
{
cookieindex = config_cookies_namesїi];
chatkeks_splitїcookieindex] = chatkeks_dataїcookieindex].split("=");
if ( typeof(chatkeks_splitїcookieindex]ї1]) != "undefined" && chatkeks_splitїcookieindex]ї1] != "")
{
chatkeksїcookieindex] = chatkeks_splitїcookieindex]ї1];
}
}
var cookiedata = "";
for (i=0; i < config_cookies_amount; i++)
{
cookieindex = config_cookies_namesїi];
if ( typeof(chatkeksїcookieindex]) != "undefined" && chatkeksїcookieindex] != "")
{
cookiedata += chatkeksїcookieindex];
}
}
oldmessages = cookiedata;
} // if (document.cookie && document.cookie != "")
} // function GetCookies()
function JsChat()
{
var cookiedata = "";
var messages = "";
GetCookies();
if ( typeof(oldmessages) != "undefined" )
{
messages += oldmessages;
cookiedata += oldmessages;
}
if ( typeof(newmessages) != "undefined" )
{
messages += newmessages;
cookiedata += newmessages;
}
if (messageid == 250) { alert("vor SetCookies(" + cookiedata + ");"); e files again, reduced to the max. The files will create output five meta-refreshes, the sixth will fail (javascript error: each_cookie[i] undefinde), because cookie2 is not readable.
Does this occur on your browser also? how do the cookies look like after 5 or 6 refresh?
thx, djot
-
chat.phpCode: Select all
<?php
$id = $_GET['id'];
$action = $_GET['action'];
$random_data_amount = 50;
if (empty($action))
{
$action = "frame";
}
if ($action == "msg")
{
for($i=1; $i<=$random_data_amount; $i++)
{
$line = $id + $i;
$msg .= "user".$line."message".$line."";
}
echo "newmessages = "".$msg."";";
}
if ($action == "frame")
{
$js_messageid = "
<script language="JavaScript">
<!--
messageid = "".$id."";
-->
</script>
";
} // if ($action == "frame")
if ($action == "frame")
{
$line = $id + $random_data_amount;
$chat ="
<html>
<head>
<meta http-equiv="refresh" content="4; url=./chat.php?action=frame&id=".$line."">
".$js_messageid."
<script language="JavaScript" src="./chat.php?action=msg&id=".$id.""></script>
<script language="JavaScript" src="./chat.js"></script>
</head>
<body>
<script language="JavaScript">
<!--
document.write(chat);
-->
</script>
</body>
</html>
";
echo $chat;
} // if ($action == "frame")
?>Code: Select all
var config_cookies_datasize = 3999;
var config_cookies_amount = 10;
var config_cookies_names = ї"a","b","c","d","e","f","g","h","i","j"];
function SetCookies(cookie-
Did you try my script?
The only explanation for not writing the cookies after refreshing and appending data over and over again is a limitation in storage size. The code itself is correct.
I know that the limit for cookies is 4kb. I did search the net for multiple cookies, but can't find an answer, some say 4kb is the limit for all cookies, some say it's 4kb each.
The second cookie does not work, when getting over ~6000 chars - what is far more then 4096byte.
But to cache (even less) then 4kb would make no sense than
I will do some further testing ...
djot
-
Did you try my script?
The only explanation for not writing the cookies after refreshing and appending data over and over again is a limitation in storage size. The code itself is correct.
I know that the limit for cookies is 4kb. I did search the net for multiple cookies, but can't find an answer, some say 4kb is the limit for all cookies, some say it's 4kb each.
The second cookie does not work, when getting over ~6000 chars - what is far more then 4096byte.
But to cache (even less) then 4kb would make no sense than
I will do some further testing ...
djot
-
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
My bad, it was per cookie.. however:
I just tested your code, after fixing some errors/warnings I was getting regarding the php, whole_cookie never had anything in it.
Client Side State - HTTP Cookies wrote:There are limitations on the number of cookies that a client can store at any one time. This is a specification of the minimum number of cookies that a client should be prepared to receive and store.Servers should not expect clients to be able to exceed these limits. When the 300 cookie limit or the 20 cookie per server limit is exceeded, clients should delete the least recently used cookie. When a cookie larger than 4 kilobytes is encountered the cookie should be trimmed to fit, but the name should remain intact as long as it is less than 4 kilobytes.
- 300 total cookies
- 4 kilobytes per cookie, where the name and the OPAQUE_STRING combine to form the 4 kilobyte limit.
- 20 cookies per server or domain. (note that completely specified hosts and domains are treated as separate entities and have a 20 cookie limitation for each, not combined)
I just tested your code, after fixing some errors/warnings I was getting regarding the php, whole_cookie never had anything in it.
-
Hi,
>My bad, it was per cookie.. however:
Yes, it's per cookie, but...
But if you set cookieA with 4000 bytes data and set cookieB with 4000bytes data, you only can read in cookieA, even if both are set with their 4000bytes (so browser can hold more than 4kb, but only gives back the first 4kb when reading the cookie).
I did read and write cookies manually with html and cookie-JS only, so no scripting this time.
cookieA - 4kb data + cookieB - 4kb data results in data of cookieA only
cookieA,B,C,D,E with ~900bytes each results in the complete data of all 5 cookies, with about 4kb in total.
cookieA,B,C,D,E,F,G with ~900bytes each results in the first 5 cookies, with about 4kb in total.
So document.cookie is defenetly not the way to read more than 4kb of cookie data, even if you have set 20 cookies with each 4kb before; You can read only the first 4kb than, the other cookies "are lost".
thx for you help. It took me about 14hours to figure that out, lol.
djot
-
Hi,
>My bad, it was per cookie.. however:
Yes, it's per cookie, but...
But if you set cookieA with 4000 bytes data and set cookieB with 4000bytes data, you only can read in cookieA, even if both are set with their 4000bytes (so browser can hold more than 4kb, but only gives back the first 4kb when reading the cookie).
I did read and write cookies manually with html and cookie-JS only, so no scripting this time.
cookieA - 4kb data + cookieB - 4kb data results in data of cookieA only
cookieA,B,C,D,E with ~900bytes each results in the complete data of all 5 cookies, with about 4kb in total.
cookieA,B,C,D,E,F,G with ~900bytes each results in the first 5 cookies, with about 4kb in total.
So document.cookie is defenetly not the way to read more than 4kb of cookie data, even if you have set 20 cookies with each 4kb before; You can read only the first 4kb than, the other cookies "are lost".
thx for you help. It took me about 14hours to figure that out, lol.
djot
-
Last edited by djot on Sun Oct 10, 2004 2:03 pm, edited 1 time in total.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
I got the script finally working with a bunch of changes.. the result
chat.php?action=frame&id=500 wrote:Bad Request
Your browser sent a request that this server could not understand.
Size of a request header field exceeds server limit.
Code: Select all
Cookie: chatkeksa=user1message1user2message2user3message3user4message4user5message5user6message6user7message7user8message8user9message9user10message10user11message11user12message12user13message13user14message14user15message15user16message16user17message17user18message18user19message19user20message20user21message21user22message22user23message23user24message24user25message25user26message26user27message27user28message28user29message29user30message30user31message31user32message32user33message33user34message34user35message35user36message36user37message37user38message38user39message39user40message40user41message41user42message42user43message43user44message44user45message45user46message46user47message47user48message48user49message49user50message50user51message51user52message52user53message53user54message54user55message55user56message56user57message57user58message58user59message59user60message60user61message61user62message62user63message63user64message64user65message65user66message66user67message67user68message68user69message69user70message70user71message71user72message72user73message73user74message74user75message75user76message76user77message77user78message78user79message79user80message80user81message81user82message82user83message83user84message84user85message85user86message86user87message87user88message88user89message89user90message90user91message91user92message92user93message93user94message94user95message95user96message96user97message97user98message98user99message99user100message100user101message101user102message102user103message103user104message104user105message105user106message106user107message107user108message108user109message109user110message110user111message111user112message112user113message113user114message114user115message115user116message116user117message117user118message118user119message119user120message120user121message121user122message122user123message123user124message124user125message125user126message126user127message127user128message128user129message129user130message130user131message131user132message132user133message133user134message134user135message135user136message136user137message137user138message138user139message139user140message140user141message141user142message142user143message143user144message144user145message145user146message146user147message147user148message148user149message149user150message150user151message151user152message152user153message153user154message154user155message155user156message156user157message157user158message158user159message159user160message160user161message161user162message162user163message163user164message164user165message165user166message166user167message167user168message168user169message169user170message170user171message171user172message172user173message173user174message174user175message175user176message176user177message177user178message178user179message179user180message180user181message181user182message182user183message183user184message184user185message185user186message186user187message187user188message188user189message189user190message190user191message191user192message192user193message193user194message194user195message195user196message196user197message197user198message198user199message199user200message200user201message201user202message202user203message203user204message204user205message205user206message206user207message207user208message208user209message209user210message210user211message211user212message212user213message213user214message214user215message215user216message216user217message217user218message218user219message219user220message220user221message221user222message222user223message223use
-
Ah ok, the header limit is about 4kb also.
But I can't read in cookies over 4kb anyway. Reading even multiple cookies results in a maximum of 4kb of data (with this script):
djot
-
-
Ah ok, the header limit is about 4kb also.
But I can't read in cookies over 4kb anyway. Reading even multiple cookies results in a maximum of 4kb of data (with this script):
djot
-
Code: Select all
<html>
<head>
<script language="JavaScript">
<!--
function GetCookies()
{
if (document.cookie && document.cookie != "")
{
var whole_cookie = document.cookie;
} // if (document.cookie && document.cookie != "")
return whole_cookie;
} // function GetCookies()
cookiedata = GetCookies();
-->
</script>
</head>
<body>
<script language="JavaScript">
<!--
document.write(cookiedata);
-->
</script>
</body>
</html>-
Where did yo uget that error message from? And the other "errors" you fixed where error_reporting('all') errors i guess, since I don't use it and had no errors.
-
Where did yo uget that error message from? And the other "errors" you fixed where error_reporting('all') errors i guess, since I don't use it and had no errors.
djotBad Request
Your browser sent a request that this server could not understand.
Size of a request header field exceeds server limit.
-
If that is accurate, it would seem to be a browser bug. Have you tested in multiple browsers, or is this specific to one browser?djot wrote: But if you set cookieA with 4000 bytes data and set cookieB with 4000bytes data, you only can read in cookieA, even if both are set with their 4000bytes (so browser can hold more than 4kb, but only gives back the first 4kb when reading the cookie).
Mind sharing the code so the rest of the audience can play along too?feyd wrote: I got the script finally working with a bunch of changes..
-
Hi, the other grandmaster of this forum has joined
, thx.
The rfc for cookies says 20 cookies with 4kb each, btw.
My final question:
document.cookie can only read in 4kb it seems. Is this done through an header response so I have the head-size-limit-problem again?
Hm, I did share all my code, reduced to the max in the end ...
djot
-
Hi, the other grandmaster of this forum has joined
The rfc for cookies says 20 cookies with 4kb each, btw.
My final question:
document.cookie can only read in 4kb it seems. Is this done through an header response so I have the head-size-limit-problem again?
Hm, I did share all my code, reduced to the max in the end ...
djot
-
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Yes, I have E_ALL forced on all scripts run on my machine. I'm a fanatic when it comes to having script errors. 
As for the changes:
As for the changes:
Code: Select all
var config_cookies_datasize = 3999;
var config_cookies_names = new Array("a","b","c","d","e","f","g","h","i","j");
var config_cookies_amount = config_cookies_names.length;
function SetCookies(cookiedata)
{
if (messageid == 200) { alert("This is the last time, all cookies are set correctly. Next time cookies are get, the second cookie is undefinde.\n\function SetCookies(" + cookiedata+ ")"); }
var start = 0;
var expiration_date = new Date("January 1, 3000");
expiration_date = expiration_date.toGMTString();
var now = new Date();
now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * 365)
for (i = 0; i < config_cookies_amount; i++)
{
cookiepart = cookiedata.substr(start,config_cookies_datasize);
cookiepart = escape(cookiepart);
cookiestring = "chatkeks" + config_cookies_namesїi] + "=" + cookiepart + ";expires=" + now;
if (messageid == 200)
{
//alert("SetCookies (i: " + i + "): MessagesID= " + messageid + "\ncookiestring=\n" + cookiestring);
}
document.cookie = cookiestring;
document.write(i + '. ' + cookiestring + '<br />\n');
start = start + config_cookies_datasize;
}
} // function SetCookies()
function GetCookies()
{
if (document.cookie && document.cookie != "")
{
var whole_cookie = document.cookie;
document.write("MessagesID= " + messageid + "<br />\nwhole_cookie=<br />\n" + whole_cookie);
var each_cookie = whole_cookie.split(";");
var chatkeks_data = new Array();
//sorting loop
for (i=0; i < each_cookie.length; i++)
{
if (each_cookieїi].indexOf("chatkeksa") > -1) { chatkeks_dataї'a'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksb") > -1) { chatkeks_dataї'b'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksc") > -1) { chatkeks_dataї'c'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksd") > -1) { chatkeks_dataї'd'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkekse") > -1) { chatkeks_dataї'e'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksf") > -1) { chatkeks_dataї'f'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksg") > -1) { chatkeks_dataї'g'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksh") > -1) { chatkeks_dataї'h'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksi") > -1) { chatkeks_dataї'i'] = each_cookieїi]; }
if (each_cookieїi].indexOf("chatkeksj") > -1) { chatkeks_dataї'j'] = each_cookieїi]; }
} // for
//splitting data and assigning final display variable
var chatkeks_split = new Array();
var chatkeks = new Array();
for (i=0; i < each_cookie.length; i++)
{
cookieindex = config_cookies_namesїi];
if(typeof(chatkeks_dataїcookieindex]) != "undefined")
{
chatkeks_splitїcookieindex] = chatkeks_dataїcookieindex].split("=");
if ( typeof(chatkeks_splitїcookieindex]ї1]) != "undefined" && chatkeks_splitїcookieindex]ї1] != "")
{
chatkeksїcookieindex] = chatkeks_splitїcookieindex]ї1];
}
}
}
var cookiedata = "";
for (i=0; i < each_cookie.length; i++)
{
cookieindex = config_cookies_namesїi];
if ( typeof(chatkeksїcookieindex]) != "undefined" && chatkeksїcookieindex] != "")
{
cookiedata += chatkeksїcookieindex];
}
}
oldmessages = cookiedata;
} // if (document.cookie && document.cookie != "")
} // function GetCookies()
function JsChat()
{
var cookiedata = "";
var messages = "";
document.write(<?= __LINE__ ?> + '<br />\n');
GetCookies();
document.write(<?= __LINE__ ?> + '<br />\n');
if ( typeof(oldmessages) != "undefined" )
{
messages += oldmessages;
cookiedata += oldmessages;
document.write(<?= __LINE__ ?> + '<br />\n');
}
document.write(<?= __LINE__ ?> + '<br />\n');
if ( typeof(newmessages) != "undefined" )
{
document.write(<?= __LINE__ ?> + '<br />\n');
messages += newmessages;
cookiedata += newmessages;
}
document.write(<?= __LINE__ ?> + '<br />\n');
document.write(<?= __LINE__ ?> + '<br />\n');
if (messageid == 250) { alert("vor SetCookies(" + cookiedata + ");"); }
document.write(<?= __LINE__ ?> + '<br />\n');
document.write(<?= __LINE__ ?> + '<br />\n');
SetCookies(cookiedata);
document.write(<?= __LINE__ ?> + '<br />\n');
return messages;
}
var chat = "";
chat = JsChat();Code: Select all
<?php
$id = isset($_GETї'id']) ? $_GETї'id'] : 0;
$action = isset($_GETї'action']) ? $_GETї'action'] : '';
$random_data_amount = 50;
if (empty($action))
{
$action = "frame";
}
if ($action == "msg")
{
$msg = '';
for($i=1; $i<=$random_data_amount; $i++)
{
$line = $id + $i;
$msg .= "user".$line."message".$line."";
}
echo "newmessages = "".$msg."";";
}
if ($action == "frame")
{
$js_messageid = "
<script language="JavaScript">
<!--
messageid = "".$id."";
-->
</script>
";
} // if ($action == "frame")
if ($action == "frame")
{
$line = $id + $random_data_amount;
$chat ="
<html>
<head>
<meta http-equiv="refresh" content="4; url=./chat.php?action=frame&id=".$line."">
".$js_messageid."
<script language="JavaScript" src="./chat.php?action=msg&id=".$id.""></script>
<script language="JavaScript" src="./chat.js"></script>
</head>
<body>
<script language="JavaScript">
<!--
document.write(chat);
-->
</script>
<br /><br /><br /><br />
$id<br />
<pre>" . var_export($_COOKIE,true) . "</pre>
</body>
</html>
";
echo $chat;
} // if ($action == "frame")
?>-
djot
-
feyd already found out, that my SetCookies function tries to send more data than possible in the header. Anyway I did test the script with Opera, Mozilla and IE. Now where I know that it's a header problem, the only question remaining is how to read in all 20 cookies. As stated above, I can't get more than 4kb with document.cookie, even if 20x4kb are set.If that is accurate, it would seem to be a browser bug. Have you tested in multiple browsers, or is this specific to one browser?
djot
-