Support the ongoing development of Laravel.io →
posted 8 years ago
Session
Last updated 1 year ago.
0

The cookie will only be available on the next request, when you receive the cookie you sent back with your response.

0

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

0

Why not just pass $affiliate_id you got from request to the view?

0

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.

0

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.

0

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.

0

To get a cookie set on current request use Cookie::queued('affiliate-id').

0

Sign in to participate in this thread!

Eventy

Your banner here too?

najela najela Joined 11 Apr 2014

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.