PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, May 16, 2022

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

 May 16, 2022     laravel, php     No comments   

Issue

On my website, on the index page, I have a bootstrap modal that shows publicities to the user when the page is loaded. I would like to hide this modal when the user would loaded the page more than 5 times, to not anoy the user.

Is there a way to do that? With session tricks?

Any sugestion? I don't find anything about this or I don't know how to find it.

Thank you!


Solution

As @AkhzarJaved said, you can do this with 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));
}


Answered By - Lucas
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing