Technique to mask pages after time limit?

ktothespencuh

New member
Jan 16, 2012
16
1
0
Does anybody know how I can display a page if a certain variable (generated by my adserver) is in the URL, but only for a limited time. And without using a database or cookies?

For example, if my ad links to a page like mysite.com/page?UNIQUE_ID=1234567 it would display a certain page (1), but if the '1234567' is missing or malformed it displays a different page (2).

However, having ?1234567 appended to the URL would only display page (1) for a certain time limit before starting to display page (2) as the plain link (mysite.com/page) does.

I generate the unique ID when the ad is served, so by the time they land on my actual site it is already appended to the URL. Therefore, anybody landing on the site via the ad would see page (1), but if they copied the URL (including UNIQUE_ID=1234567) and came back a couple days later they would see page (2).

Once they land on the landing page I generate a time(); and send that back to my tracking script along with the unique ID... if that can help somehow?

I'd prefer a PHP solution, perhaps working with elseif and echo to display a certain page based on variable and time.

Is this possible without writing anything to a database???

If you know what I'm talking about, please do mention what kind of PHP statements I could use. Doesn't have to be PHP either, that's just what I'm used to.

Finally, I'm not necessarily asking you to teach me how to do it, I'm mostly asking if a) it's possible, and b) what's are some keywords I could use to learn more about how it's done.

Thanks for any help,
 


This is how I would do it in python, using itsdangerous — itsdangerous

Code:
In [1]: from itsdangerous import URLSafeTimedSerializer

In [2]: s = URLSafeTimedSerializer('my secret')

In [3]: token = s.dumps('12345')

In [4]: print token
IjEyMzQ1Ig.BrezEA.W2-2gW48xIFlhnEkEpMcyeodmnc

In [5]: print s.loads(token)
12345

In [6]: print s.loads(token, max_age=2)
---------------------------------------------------------------------------
SignatureExpired                          Traceback (most recent call last)
<ipython-input-6-efd12d5af650> in <module>()
----> 1 print s.loads(token, max_age=2)

/usr/local/lib/python2.7/site-packages/itsdangerous.pyc in loads(self, s, max_age, return_timestamp, salt)
    641         """
    642         base64d, timestamp = self.make_signer(salt) \
--> 643             .unsign(s, max_age, return_timestamp=True)
    644         payload = self.load_payload(base64d)
    645         if return_timestamp:

/usr/local/lib/python2.7/site-packages/itsdangerous.pyc in unsign(self, value, max_age, return_timestamp)
    461                     'Signature age %s > %s seconds' % (age, max_age),
    462                     payload=value,
--> 463                     date_signed=self.timestamp_to_datetime(timestamp))
    464
    465         if return_timestamp:

SignatureExpired: Signature age 18 > 2 seconds

It's saving the unique value (12345) with the creation time, then signing it, using the secret. This value would then be included in your URL. If it's decoded with a max_age, it'll throw an exception if it's too old. The exception can be caught, and a different page served. Maybe PHP has a similar package.