Check for unique id during multiple posts

I am looking to attach a random id as a $_GET[] parameter to a form. The form is an upload script with multiple post occurring per session.

I need to check that id on the server side page to see if this $_GET[‘id’] has arrived for the first time or not.

Meaning when handler.php?id=iouhv9hc82hco2i3y8 has been executed, if the post with $_GET[‘id’] = iouhv9hc82hco2i3y8 is new for the first time run this script and all other requests with the same id run another script.

I have tried - sessions and cookies and unless I am placing this is the wrong order all I get is the session or cookie writing itself and running the first script.


session_start();
$_SESSION['unique'] = $_GET['id'];

if (isset($_GET['id']) == $_SESSION['unique']) {
    print 'first';
}
else {
    print 'second';
}