hi i cant figure this out for the life of me
<script language="JavaScript">
cookie_name = "dataCookie";
function getName() {
if(document.cookie)
{
index = document.cookie.indexOf(cookie_name);
if (index != -1)
{
namestart = (document.cookie.indexOf("=", index) + 1);
nameend = document.cookie.indexOf(";", index);
if (nameend == -1) {nameend = document.cookie.length;}
YouWrote = document.cookie.substring(namestart, nameend);
return YouWrote;
}
}
}
YouWrote=getName();
document.write(YouWrote);
</script>
if the cookie doesnt exist then YouWrote = undefined is there a way to get round this, i know this is easy in php but dont ask
if(isset($_COOKIE["name")) {
echo $_COOKIE["name"];
} else {
//do nothing or echo something else
}
can anybody help me? thanks
Rich



Reply With Quote
Bookmarks