Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

raviawasti's avatar

I want to add a disclaiamer popup section in laravel whenever any user try to open my website first time

I want to add a disclaiamer popup section in laravel whenever any user try to open my website first time, with some message like

"This is to inform user / customer(s) that www.testing.com, testing.com are the only official websites of Godrej Properties Limited (“Company”). User/Customer(s) are cautioned and advised not to rely upon any information stated on any other websites which may appear to be similar to the company’s official website, including containing company’s logo / brand name."

With a button to Agree, only after user click on agree button they will be able to see my full website. After clicking on agree buton first time it must not show all the time whenever a user refresh the page. Kindly guide me how do i implement this.. I am stuck and not able to find any solution on google.

Refrence image:- https://photos.app.goo.gl/Ltn8Z1TpfrYwLjTM8

0 likes
6 replies
gych's avatar

You could go for an approach like this:

  • Create a DB table where you store the user ip and if the user has agreed to the disclaimer popup.
  • When the user agrees, add the user IP to the DB with for example a column named agreed set to true.
  • For each visitor you can check if the IP already exists in that table and show the popup message based on this check.
gych's avatar

@raviawasti I could be wrong but I don't think that there's a package available that does this for you. You should try to implement this yourself, if you have more questions or get stuck you can always ask for more help.

1 like
JussiMannisto's avatar

@raviawasti Not everything needs a package. This is a very simple feature and @gych even laid out one solution for you.* Learning and configuring a 3rd party package would be more complicated than just making this feature yourself. If you don't know how to do this, then it's a good excercise.

* Except you shouldn't use an IP address for tracking, use a session variable instead. An IP address isn't a realiable way of identifying a user. Consider the IP of a hotel wifi; countless people will be using that. And if your user is on mobile data, they'd get pretty sick of closing and re-closing the notification when their IP changes. Or they might never see it if someone with their current IP saw it previously.

1 like
Snapey's avatar

You can use a GDPR package and change the wording.

Eg https://github.com/spatie/laravel-cookie-consent

The solution should check for a cookie from the client. If they don't have the cookie, show them the notice. When they click accept, give them the cookie so that next time on the same device, they skip this step.

Checking the visitors IP is a very crude approach that does not work in the following scenarios;

  • people working from an office will likely all share the same IP address. One accepting is the same effect as all of them accepting
  • a user on their own networks will see the message each time their IP changes. Eg, at home, in the office, at a cafe, using their phone as hotspot.
1 like
martinbean's avatar

@raviawasti Use a cookie?

If the cookie is not set, show the modal. When the user dismisses the modal, set a cookie to prevent it from showing on subsequent page loads.

Please or to participate in this conversation.