The cookie will only be available on the next request, when you receive the cookie you sent back with your response.
Xum said:
The cookie will only be available on the next request, when you receive the cookie you sent back with your response.
I would like to get the cookie in the current request and not the next one
Xum said:
Why not just pass
$affiliate_id
you got from request to the view?
The problem is that the $affiliate_id variable must not necessarily be used the first time the user visits the view. I am keeping it just in case the user visits that view later.
Well, use cookie value if it's set and fallback to Input::get('affiliate-id')
if it's not. That way you'll have affiliate_id in your view on both the first visit and consequent ones.
Xum said:
Well, use cookie value if it's set and fallback to
Input::get('affiliate-id')
if it's not. That way you'll have affiliate_id in your view on both the first visit and consequent ones.
Thanks for your wise suggestions. I was looking for a method of getting the cookie without having to go through this.
To get a cookie set on current request use Cookie::queued('affiliate-id')
.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community