Click to See Complete Forum and Search --> : saving variables to cookies


davey
11-24-2003, 06:10 PM
i want to save the variables in this code to a cookie

<script type="text/javascript">
<!--
var global=50;
function SetGlobal(param){
global+=param;
return global;
}

function Process(){
alert ("Original power = "+global+", new power = "+SetGlobal(50));
}
function Process2(){
alert ("Original power = "+global+", new power = "+SetGlobal(100));
}
function Process3(){
alert("Original power = "+global+", new power = "+SetGlobal(150));
}
function Process4(){
alert("power = "+global+" ");
}
var money=10000;
function Setmoney(param){
money+=param;
return money;
}
function Process5(){
alert("Original money = "+money+", current balance = "+Setmoney(500));
}
function Process6(){
alert("Original money = "+money+", current balance = "+Setmoney(200));
}
function Process7(){
alert("Original money = "+money+", current balance = "+Setmoney(50));
}
function Process8(){
alert("money = "+money+" ");
}


//-->
</script>


if possible i want to save var global and var money to the same cookie

Khalid Ali
11-25-2003, 06:42 AM
you should be able to do that,here is a link for simple cookie usage (http://www.webapplikations.com/pages/html_js/document/SimpleLoginCookieScript.html),I hope it will help.