To solve your problem, there are two solutions:
Javascript
You need to write a JS that will set the cookie to watch this or that video, and when you reload the site, change to another. Example:
// функции для работы с куками function getCookie(name) { var matches = document.cookie.match(new RegExp( "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" )); return matches ? decodeURIComponent(matches[1]) : undefined; } function setCookie(name, value, options) { options = options || {}; var expires = options.expires; if (typeof expires == "number" && expires) { var d = new Date(); d.setTime(d.getTime() + expires*1000); expires = options.expires = d; } if (expires && expires.toUTCString) { options.expires = expires.toUTCString(); } value = encodeURIComponent(value); var updatedCookie = name + "=" + value; for(var propName in options) { updatedCookie += "; " + propName; var propValue = options[propName]; if (propValue !== true) { updatedCookie += "=" + propValue; } } document.cookie = updatedCookie; } function deleteCookie(name) { setCookie(name, "", { expires: -1, path: "/", domain: window.location.hostname }); } // example // setCookie("cookieName", "cookieValue", { expires: expireTime, path: cookiePath, domain: allowedDomain, secure: useOrNotHttps }) // setCookie("langsite", "ru", { expires: 30*24*60*60, path: "/", domain: "eshko.ua", secure: false }) // expires: in one month // path: on all site // domain: eshko.ua // secure: use http // Сам код: $(document).ready(function(){ if (getCookie('LastVideoIndex') > 0) { var newIndex = getCookie('LastVideoIndex') + 1; setCookie('LastVideoIndex', newIndex); $('source').attr("src", './vid/'+newIndex+'.mp4'); } else { setCookie('LastVideoIndex', 3); } });
Php
In essence, the same thing is only using session for data storage. Insert inside the HTML page the file is renamed in PHP and set up .htaccess .
<?php if (isset($_SESSION['lastVideoIndex']) && $_SESSION['lastVideoIndex'] > 0) { $_SESSION['lastVideoIndex']++; } else { $_SESSION['lastVideoIndex'] = 3; } echo '<source src="./vid/'.$_SESSION['lastVideoIndex'].'.mp4" type="video/mp4">'; ?>