如何在用户重新加载页面 x 次后隐藏宣传 Laravel

How to hide a publicity after user has realoded the page x times Laravel

在我的网站上,在索引页上,我有一个 bootstrap 模态,在加载页面时向用户显示宣传。我想在用户加载页面超过 5 次时隐藏此模式,以免打扰用户。

有办法吗?使用会话技巧?

有什么建议吗?我没有找到任何相关信息,或者我不知道如何找到它。

谢谢!

正如@AkhzarJaved 所说,您可以使用 JS localStorage

let pubViews = parseInt(localStorage.getItem('pub_views')) || 0;
if (pubViews < 5) {
     document.querySelector('#publicities').style.display = 'block'; // or other display value
     localStorage.setItem('pub_views', (pubViews + 1));
}