First, Set a cookie you can use the following code:
$ref = 'my cookie value'; return redirect('/')->withCookie('ref', $ref);
Second, get a cookie value by doing the following:
$cookie = $request->cookie('ref');
And it's as easy as that. To learn more about laravel cookies you can visit the official documentation.
Additionally you can learn more about Laravel cookies by checking out this video: