You can set a variable in $_SESSION
and check if it was set at the time of displaying the preload, in the case of PHP it would look something like this:
<?php
session_start();
if (empty($_SESSION['preload'])) {
$_SESSION['preload'] = true;
//código para mostrar o preload
}
?>
With JS you can do using cookie for example:
function setCookie(cname, cvalue, days) {
var d = new Date();
var expires;
if (days) {
d.setTime(d.getTime() + (days*24*60*60*1000));
expires = "expires="+ d.toUTCString();
}else {
expires = "";
}
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
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 "";
}
function checkPreload() {
var preload = getCookie("preload");
if (preload == "") {
console.log("mostrar preload");
setCookie("preload", 1, 1);
} else {
console.log("já mostrou o preload");
}
}
checkPreload();