The cookie value of 'x' is 'krul=1', not '1' like in your conditional statement.
You may want to parse the cookies prior to the 'if' statement to get the individual cookie value you need. Otherwise, you would need to check if the value of 'x' is equal to 'krul=1'.
Of course the latter method isn't really ideal. The first method would be preferred and easier for you to deal with cookies long term.
There are many ways to accomplish this, but here's the example from W3Schools to get the document cookie value via javascript:
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
}
return "";
}
So, if you were to add the above snippet to your script then your code should call the 'getCookie' function to get the value.
The new code would then look something like:
document.cookie="krul=1";
var x = getCookie("krul");
if(x == 1){
document.getElementById("krul").src="https://www.youtube.com/v/An9M93j2XUs?version=3&loop=1&playlist=An9M93j2XUs&autoplay=1";
}