I am having a problem with cookies. I have another script that stores the following cookies:
username
luckynumber
sign
I am trying to retrieve the cookies and assign the cookie names as the indices of an array and the cookie values as the corresponding values in the array. When I try to display the values, all but the first are undefined.
Any clues?
username
luckynumber
sign
I am trying to retrieve the cookies and assign the cookie names as the indices of an array and the cookie values as the corresponding values in the array. When I try to display the values, all but the first are undefined.
Code:
[blue]if( document.cookie ) {
var myCookie = document.cookie;
var temp = myCookie.split( ";" );
var cookies = new Array( temp.length );
for( var i = 0; i < temp.length; i++ ){
var hold = temp[ i ].split( "=" );
cookies[ hold[ 0 ] ] = hold[ 1 ];
}
document.write( "Username: " + cookies[ "username" ] +
"<br />Lucky Number: " + cookies[ "luckynumber" ] +
"<br />Sign: " + cookies[ "sign" ] );
}[/blue]
Any clues?