views:

44

answers:

1
  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.

+2  A: 

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

rikh