Store in value in cookie

I’m new to using cookies. I am using JavaScript for a web project and I’m using cookies and I have 5 links for different movie trailers and I have a trailers.html page with a div with a id=“movie” and want to know so that when you click on a Movie trailer link so that it stores a value in a cookie so that you can check on the trailers page which trailer was chosen and display in the div tag

Allow me to introduce you to this AWESOME NEW TOOL for learning how to do anything.

These are the standard cookie-handling functions to create, read, and erase a cookie:


function createCookie(name, value, days) {
	var expires = '',
        date = new Date();
    if (days) {
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        expires = '; expires=' + date.toGMTString();
    }
    document.cookie = name + '=' + value + expires + '; path=/';
}

function readCookie(name) {
    var cookies = document.cookie.split(';'),
        length = cookies.length,
        i,
        cookie,
        nameEQ = name + '=';
    for (i = 0; i < length; i += 1) {
        cookie = cookies[i];
        while (cookie.charAt(0) === ' ') {
            cookie = cookie.substring(1, cookie.length);
        }
        if (cookie.indexOf(nameEQ) === 0) {
            return cookie.substring(nameEQ.length, cookie.length);
        }
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, '', -1);
}