Hello,
I made a page that creates a cookie with multiple properties/ values. when I recall the cookie I split them up and put them into an assiociative array.
but when I try to recall them IE gives "error: stored_info is not defined". I have placed "<<<<<<<<" where the error occurs.
code to create cookie
code to get the cookie information
here I want to get information from stored_info, but then the error is given.
I tried several other options and variables, but nothing seems to work.
I hope someone can help me out of this.
Wouter
I made a page that creates a cookie with multiple properties/ values. when I recall the cookie I split them up and put them into an assiociative array.
but when I try to recall them IE gives "error: stored_info is not defined". I have placed "<<<<<<<<" where the error occurs.
code to create cookie
Code:
//create cookie
var cookie_inhoud = "test1:1~test1:2"
document.cookie = "test_cookie=" + escape(cookie_inhoud);
code to get the cookie information
Code:
//get cookie
function getCookie() {
var original_cookie = document.cookie;
var decoded_cookie = unescape(original_cookie);
//remove cookie title
var cookie_splitted = decoded_cookie.split("=");
var cookie_contains = cookie_splitted[1];
//put the rest into an array
var cookie_contains_splitted = cookie_contains.split("~");
//split the rest with a loop
for (var loop = 0; loop < cookie_contains_splitted.length; loop++) {
var cookie_loop1 = cookie_contains_splitted[loop];
var cookie_loop2 = cookie_loop1.split(":");
var property = cookie_loop2[0];
var value = cookie_loop2[1];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<error below
stored_info[property] = value;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<error above
}
}
here I want to get information from stored_info, but then the error is given.
Code:
function test() {
stored_info = new Array();
getCookie(stored_info);
alert(stored_info["test1"]);
}
I tried several other options and variables, but nothing seems to work.
I hope someone can help me out of this.
Wouter