I have this javascript function which I need somehow to be remembered by cookies.

function load(){


if (window.frames[0].document.getElementById('applications'))
{
var n=str.replace("Login","Logout");
document.getElementById('common').href='../css/common2.css';}}
I understand I need to set a flag in the cookie and when the page loads check that cookie for the state.

So, cookies script is :

function setCookie(c_name, value, exdays) {
var exdate = new Date();
if (exdays) exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays) ? '; expires=' + exdate.toUTCString() : '');
document.cookie = c_name + "=" + c_value;
}

function getCookie(name) {
var re = new RegExp(name + "=([^;,]+)");
var value = re.exec(document.cookie);
return (value !== null) ? unescape(value[1]) : null;
}
I have problems setting the flag in the cookie and check for cookie state.

if (window.frames[0].document.getElementById('applications')
&& !getCookie('authentication'))
{
var n=str.replace("Login","Logout");
document.getElementById('common').href='../css/common2.css';
setCookie('authentication','1',1);}