How can I read Cookie through Webhook in PHP? -


i'm using selz.com process payments , can use test webhooks files.

for example, have whtest.php.

if(isset($_cookie['affiliate'])) {     $aff_code = $_cookie['affiliate']; } file_put_contents('webhook_data.txt', $aff_code, file_append);    //webhook $json = json_decode(file_get_contents('php://input'), true); file_put_contents('webhook_data.txt', $json, file_append); 

the cookie there. if go whtest.php , access directly browser write cookie data inside webhook_data.txt. that's fine.

the problem if send test random webhook data whtest.php gets successfuly webhook_data.txt not data cookie too. how can solve this?

the short answer can't use cookie in circumstance. webhook have no knowledge of cookie set user on site.

i'm not familiar selz (so sorry can't more specific), you'll have find piece of data sent in webhook have access prior user making purchase. shopping cart id, transaction id, order id, session token, etc. identifier unique user's purchase.

once have data, need make call server prior purchase happening, , persist in database relationship of id -> affiliate_sale. once webhook call made, use piece of data sent selz lookup match in database. can whatever have if affiliate sale.

hope helps


Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -