开发者

How to store affiliate ID correctly to browser

开发者 https://www.devze.com 2023-01-04 05:58 出处:网络
I want to create a simple affiliate code. Currently I use PHP session to keep the affiliate ID. http://domain.com/aff.php?id=123
  1. I want to create a simple affiliate code.
  2. Currently I use PHP session to keep the affiliate ID. http://domain.com/aff.php?id=123

    $_SESSION['referral'] = intval($_GET['id']);

The problem now. Example user logged to affiliate area then logout, the $_SESSION['referral'] will unset & destroyed by session_unset() session_destroy() on logout.php

So now the affiliate ID no more on the page. So we need to retype the URL to get the ID sticked on the 开发者_开发知识库whole web pages.

Question

How to make the affiliate id id=123 will be on the browser although session already destroyed. Unless user clear the browser cache.


You could set the affiliate id into a cookie, so it is still available after the session expires.

setcookie("affiliate", intval($_GET['id']);

see setcookie

0

精彩评论

暂无评论...
验证码 换一张
取 消