![]() |
PHP people...quick question
What's the best way to approach easily creating expiring links?
Links that expire after the first click? Or after a certain amount of clicks or time. Whichever is easier. |
And by expire you mean?
|
1 click. link gone.
|
Never tried it but maybe a CSS thing:
a:visited { display: none; } ? |
Quote:
What I want to do is after a potential client visits a page. I don't want them to be able to go to that page again. Unless I send them a fresh link. |
Quote:
<?php // on page being hit if(isset($_COOKIE["alreadyhere"])) { header("Location: /another/uri"); } else { setcookie( "alreadyhere", 1, (time()*100000), $_SERVER["REQUEST_URI"] ); } ?> -- or some shit. basically, store something of the URI they already visited, test and send somewhere else. someone else has a more elegant solution that's bug-checked, so I'll just bump this for ya :) |
Quote:
ill take anything else anyone can throw at me though. |
Quote:
if you want to do it with a database, rather than a cookie... in the email, you have an ID like ID=12 that is unique to the person.. or the ID is for a particular URL and after so many incremental clicks, you do something else. when they land on your page, you mark in the database that they visited via the unique ID (so this helps you to confirm they clicked through), and the next time they click through on the email, your database lookup will see they were already there, and then redirect to another URL or display some message. Fight the tips & tricks! |
i am not a php pro by any means, i have my own threads on here asking for help ;) but what if you set a status for the links? on the main page it only shows "active links" and when they click, you have a variable that sets it inactive, thus it wont be shown on the main page anymore after a click. Just an idea
|
Do this in a database. Store a unique id for each link sent (i.e. md5($email . time()); ) using the md5 hash prevents people guessing for someone else's link (by incrementing a numeric value like id=5 as suggested above).
In your db table also have a field for date_clicked which you update when the url is loaded. You could also have a campaign_id or something to track multiple links mailed in the same table, maybe the email address as well, whatever suits your needs. Then you send a link like : http://www.someurl.com/somepage.html...23456789abcedf When the link is loaded you check the db for that hash and whether date_clicked has been set or not. Redirect or load the one time link page based on those conditions and then update the db. |
Thanks Swish and Fight This Patent, I think I'll mesh your two ideas hash + lookup
thanks to you too pipecrew. good to see you still posting around here. hows miami treating you? |
Quote:
|
Use PHP's APC Cache.
Put the link URL in a key in apc cache, once it's been accessed, destroy the key. http://us.php.net/apc |
database + unique hashes is the only sure shot way to go at this.
it what i would do. |
href="myScript.php?linkID=xxxx"
then the myScript.php redirects and removes the link as a valid option you can probably use a database as the easiest way to keep track of it |
do you still need this?
i know its a very old thread, but i use something like this, you can make the url expire after certain amount of time. bind it to an ip address, etc. |
All times are GMT -7. The time now is 02:41 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123