Support the ongoing development of Laravel.io →
posted 10 years ago
Requests
Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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
}

Source: http://laravel.com/docs/requests#cookies

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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
Last updated 2 years ago.
0

does this work with laravel 5?? it doesn't seem to work with me

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.