Adding a cookie's value to itself...

wxdqz

New Member
Hello everyone,

I don't even know if this is possible, but don't see why it wouldn't be.

My question is very simple to word and I hope an answer comes just as easily.

How do you add the value retained in a cookie to an equation within the same cookie?

i.e.
TimeIn = new Date();

function SetCookie() {
var TimeOut = new Date();
var today = new Date();
var expire = new Date();
var nDays=2;
var cookieName="SomeValue";
var TimeSpent=(TimeOut - TimeIn);
var TimeRemaining=(SomeValue + TimeSpent);
var cookieValue=TimeRemaining;
expire.setTime(today.getTime() + 600000);
document.cookie = cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString();
}

The variable TimeRemaining would become the value of the cookie's previous value plus (+) the value of the variable TimeSpent.

Of course, the first time the cookie is set, the value of "SomeValue" in the equation would be zero (0).

Thanks!

~D
 
Back
Top