OK guys, this should be a simple one, but I know next to nothing about javascript...
I am using the following code to write a cookie
And then the following to get/write it into a document
It isn't returning anything though. What am I doing wrong?
I am using the following code to write a cookie
Code:
<script type="text/javascript">
function setCookie(){
var cookieName="UserName";
var cookieValue="Duminda";
var expiryDate = new Date();
var oneDayFromNow = expiryDate.getTime() + (24 * 60 * 60 * 1000);
expiryDate.setTime(oneDayFromNow);
document.cookie = cookieName+"="+escape(cookieValue)+";expires="+expiryDate.toString()+";";
return true;
</script>
And then the following to get/write it into a document
Code:
<script type="text/javascript"> document.write(getCookie('UserName')); </script>
It isn't returning anything though. What am I doing wrong?