Very nice and very useful. Thank you.
I use it with a small change.
I moved the code to write the referrer into the session
if ($request->has('ref')) {
session(['referrer' => $request->query('ref')]);
}
from app/Http/Controllers/Auth/RegisterController.php to a custom made middleware app/Http/Middleware/CheckReferrer.php
That way, the ?ref=referrer can be used on any link on the website and not only on register?ref=referrer
P.S. The custom middleware can be created using the artisan command: php artisan make:middleware CheckAge
then it has to be registered within app/Http/Kernel.php
Nice suggestion Clement. Although I think the session won't last much and it can be replaced if the user visits a page with a new ref parameter.
I need to keep the referrer value for at least 7 days and set the value only if it's not already there. For this particular case I think I will be using Cookies.
Very nice and very useful. Thank you.
I use it with a small change.
I moved the code to write the referrer into the session
from
app/Http/Controllers/Auth/RegisterController.php
to a custom made middlewareapp/Http/Middleware/CheckReferrer.php
That way, the
?ref=referrer
can be used on any link on the website and not only onregister?ref=referrer
P.S. The custom middleware can be created using the artisan command:
php artisan make:middleware CheckAge
then it has to be registered within
app/Http/Kernel.php
Nice suggestion Clement. Although I think the session won't last much and it can be replaced if the user visits a page with a new ref parameter.
I need to keep the referrer value for at least 7 days and set the value only if it's not already there. For this particular case I think I will be using Cookies.
This is great. I really didn't think about this use case as mine was only focused on registration