To be honest, I am really bad at Javascript.
I want to create something that will do the following:
on post page: on click, set cookie.
on home page: If cookie is set, echo the page the cookie was set on.
I assume that this can be done using javascript and innerhtml?
The only clue I've found so far is this code, which I do not get at all.
Help is appreciated.
Thanks.
function setcookie(name,value,exp){
var expdate=new Date();
expdate.setDate(expdate.getDate()+exp);
document.cookie=name+'='+value+';expires='+expdate.toGMTString()+';path=/';}
function set_lw(sid,eno,cc,ow,reset)
{
if(reset==0){if(cc<20||ow==1){
setcookie('LW_'+sid,eno,365);document.getElementById('last')
.innerHTML='<div id="marked"><a href="#" onclick="set_lw('+sid+',\''+eno+'\','+cc+','+ow+',1);return false"></a></div>';
}
else
{
alert('Ops, you have set too many cookies!');
}}
else
{
remove_lw(sid);document.getElementById('last')
.innerHTML='<a href="#" onclick="set_lw('+sid+',\''+eno+'\','+cc+','+ow+',0);return false"></a>';}}
function remove_lw(sid){
setcookie('LW_'+sid,'none',-1);
alert('Cookies has been removed.');}