Create Cookies Hide and Show DIV in JS

Create Cookies Hide and Show DIV in JS

I have made a button <onclick="define_v();"> to hide and show the div.

Now I want to set the cookies to set the last action.

Here is the JS that i write.
<script>
var y=1;
function define_v(){
if(y == 1){
comeout
();
y
= 0;
} else if(y == 0){
  comein
();
  y
= 1;
 
}
}


function comeout(){
t6
= new Tween(document.getElementById('sideslide').style,'right',Tween.
regularEaseOut
,-300,0,.5,'px');
t6
.start();
}


function comein(){
t5
= new Tween(document.getElementById('sideslide').style,'right',Tween.
regularEaseOut
,0,-300,.5,'px');
t5
.start();
}
</script>