There's a general rule about things like this. Only pass to and from the user what you HAVE to to get this to work.
For instance, setting a cookie seems great. Til some dickweek punk (like me :-) figures out how to toss the right cookie with wget and grab all the pics from you site in a flicker of an eye, and passes it around in an IRC chat room (unlike me, I'd only do it for myself.... ;) and suddenly you're in the hole $400.00 for bandwidth with 2 $5.00 sales. :-(
Assume the little weenies are looking at how to hack you. Don't do anything that will let them.
OK, back to the issue at hand. Let's say you set a pin. We'll use some randomly generated alpha-numeric from 000000 to zzzzzz for this test. I use Postgresql, you get to translate if necessary.
create table pin_numbers (
id serial,
pin char(6),
start_time timestamp without time zone,
end_time timestamp without time zone,
fieldx text
);
$now=date(); <-- you figure out the time.
select id from pin_numbers where start_time <$ 'now ' and end_time > '$now';
if you get back the id, the pin is valid, if not, it isn't. every 24 hours go in and delete obsolete pins.