- 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
$_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
精彩评论