document.cookie

admin

Administrator
Staff member
Hi there!

I have used to following script to write a cookie that contains data from form input:
function writeCookie()
{
var cookieName = "MyCookie"
var name = document.form1.firstname.value;
var lastname = document.form1.lastname.value;
var flower = document.form1.flower.value;

var nextYear = new Date();
nextYear.setFullYear(nextYear.getFullYear() + 1);


var cookie = "MyCookie=" + cookieName + "; version=" + document.lastModified + "; expires=" + nextYear.toGMTString() + "; secure ;" + " |" + name + "|" + lastname + "|" + flower + "|" ;


document.cookie = escape(cookie);
}

And to some extent this works in that it is possible to unescape(cookie) and read the data back. However, the cookie does last beyond the session despite the expires date being set.

can any one tell me why and show me how to correct the problem?

TIA

Tricky
 
Back
Top