Click to See Complete Forum and Search --> : Cookie problem


Shampie
10-16-2003, 11:56 AM
Hello,

When I execute 'LoadGame(the_info)' via a link it should callup the function below, however it return an error that 'the_info' is undefined.
I can add var the_info = ""; inside but the 'hitp' will be undefined.
What is wrong within the code?


function savegame(){
var hp = this.parent.form.playerhp.value;
var acb = this.parent.form.acb.value;
var locx = this.parent.form.prex.value;
var locy = this.parent.form.prey.value;
var locz = this.parent.form.prez.value;

var mid = this.parent.form.identityx.value;
var minf = this.parent.form.info.value;
var hmap = this.parent.form.htmfile.value;
var info = "hitpoints:"+hp+"/armor:"+acb+"/locx:"+locx+"/locy:"+locy+"/locz:"+locz+"/mid:"+mid+"/minf:"+minf+"/hmap:"+hmap+"";
var the_cookie = "psg_cookie_save1=" + escape("psg_cookie:" + info);
var the_date = new Date("March 31, 2023");
var the_cookie_date = the_date.toGMTString();
the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie = the_cookie;
alert("saved.."+info+"");
}

function LoadGame(the_info)

{
var the_cookie = document.cookie;
var the_cookie = unescape(the_cookie);
var broken_cookie = the_cookie.split("=");
var the_values = broken_cookie[1];
var separated_values = the_values.split("/");
var property_value = "";
for (var loop = 0; loop < separated_values.length; loop++)
{
property_value = separated_values[loop];
var broken_info = property_value.split(":");
var the_property = broken_info[0];
var the_value = broken_info[1];
the_info[the_property] = the_value;
var hitp = the_info["hitpoints"];


}
alert("Game loaded.."+hitp+"");

}

Shampie
10-16-2003, 09:01 PM
can't find the problem :|