tags:

views:

258

answers:

1

I have a simple file called index.php. I need to pass it a querystring that will be stored inside a never-expiring cookie. The file looks exactly like this :

<?php

if (isset($_GET['referrer_id']))
{
    $querystringWithJunk = $_GET['referrer_id'];
    $querystringArray = explode('/', $querystringWithJunk);

    setcookie("referrer_id", $querystringArray[0], time() + 60*60*24*365*100);
}?>

However, no cookie is set. What is inside referrer_id is a simple integer (in the tests I made, it's 1). Function setCoookie return true and everything seems to works fine but no cookie is set. Am I doing something wrong?

+8  A: 

Time is bigger than int, so I think result is negative, and then cookie is set into past, what means, it is deleted. Set time to 3 years instead of 100.

Thinker
That was exactly the problem, thank you very much!
Sebastien Lachance