B
B
bastian192018-07-23 23:01:42
Laravel
bastian19, 2018-07-23 23:01:42

How to store ref_id in cookies?

A question. I'm making a referral system.
If the user follows the ref link, then two conditions follow: the user does not have a ref ID from the ref link in the cookie, or he does. If it is, then we do nothing. If not, then add the ref id to the cookie.
Verification is needed because: if the user follows the ref link, but does not register, then the ref ID will be saved in cookies. And if he goes back to the main page ( https://domain), then the value of the ref id in the cookie will be replaced by a null value.
How can it be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Skobkin, 2018-07-23
@skobkin

And what's the problem? Show your code what is not working?

filter_has_var(INPUT_COOKIE, $refIdCookieName );
filter_input(INPUT_COOKIE, $refIdCookieName , /* ... */);
setcookie($refIdCookieName , $cookieValue);

UPD: If anything, the functions above are for pure PHP. For Laravel, it's better to work with the Request object .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question