It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Cookie Problem

Cookie Problem

Postby shivam543 on Tue Sep 20, 2011 6:22 am

var number= new Array(4);
// tell me whats the problem with code in the end
var x;
var u;
function redirect()
{
window.location="puzzle1m2.html"
}

function randomx()
{
x=(Math.floor(Math.random()*10))
document.write( x );
}

for (i = 0; i < 5 ; i++)
{
randomx()
number[i]=x;
}
var u = number[0]+number[1]+number[2]+number[4]+number[3]
document.write("<br>"+u);

if (u>24)
{
document.write("<br>" + '<span style="color:sienna;font-size:29px;">'+"You Are Lucky... Redirecting"+"</span>");
var time=setTimeout("redirect()",5000);
}
else
{
document.write("<br>" + '<span style="color:sienna;font-size:29px;">'+"You Failed.. Redirecting to Google.com"+"</span>");
var ti=setTimeout("redirect2()",1000);
}

function redirect2()
{
window.location="http://www.google.com"
}
// all the script upto here works very well


var expdate= new Date();
expdate.setMonth(expdate.getMonth()+1);
// if i document.write date it works
var cookieVal=u;
document.cookie = newCookie + "=" + cookieVal + ";path=/;expires = "+expdate.toGMTstring();
// but here cookie does not gets stored
//what do i do please help me
// i want to store u(VARIABLE) in client's pc using cookies
// i also want to get the cookies but first storing is essential
// i know how to check cookies once stored
shivam543
 
Posts: 1
Joined: Tue Sep 20, 2011 6:16 am

Who is online

Users browsing this forum: No registered users and 6 guests