Make the cookie last X days. If the cookie doesn't exist later in your application, that means X days have passed.
So to display your modal every X days, just check that the cookie doesn't exist. And then make the cookie again.
To create your cookie you need to use on the route associated with the homepage:
Cookie::queue($name, $value, $minutes);
To check if the cookie exists do something like:
if (Cookie::get('myCookie') !== false) {
//do stuff
}
I'm not understand. So i have to create cookies for new user who comes on website (any page). And after X days i want to show them popup which i included in my posts.show.
I don't know in which method i have to set up cookies, and in which method i have to grab the cookie.
Put your newsletter form inside
if (Cookie::get('myCookie') !== false) {
//do stuff
}
If this is in a blade view it should look like:
@if (Cookie::get('myCookie') !== false)
//do stuff
@endif
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community