Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Page active for 48hrs

Status
Not open for further replies.

Wulfgen

Technical User
Dec 31, 2004
283
US
I've tried different combinations of search for this but...

Is there a script out there that will only allow the page to be active for 48hrs after the initial load?

EG: A download link page that will be unusable after a certain amount of time has elapsed from when a user first loads it? they can download once or twice, but after that.... no.
 
Does your user have to login or use a username etc?
If so, you can assign the sign in date into the database and work out the 48 hours as an end time thereby stopping a particular user.

You could also use a cookie on their machine. Obviously if they clear the cookies then they will be able to access the page again.

Reality is built on a foundation of dreams.
 
I'm trying to have a download page where after the user purchases the product they will have a link in their receipt. The user then clicks on the link and on the page is a download button, but it will only be available for 48hers (after) they initially load the page - after that its gone...

Make sense? or am I mad?
 
I suppose you could always use mysql to store the time it expires and an order id and validate against that for the download page.

So, when they click the link which will have the order id in the string (something like php queries mysql for the id, checks the expiry date and if it is still valid it allows the download to go ahead.

You might need to tweak the idea if you are providing different products for download so it has an item id number too, but I would have thought it would work.

Richard
 
use the download link as your solution..
start with inserting time in the database,
as soon as the person clicks the link, time and expiry date will be inserted in your mysql database..

(start date) (end date)
INSERT INTO db VALUES (timestamp, timestamp + 2 days)

Hope this helped.


Grtz, Bertjh
 
Probably, yes if I knew (anything) about mysql (hahaha) I guess i now have to learn about how to use it - spose its time.....
 
or to avoid databases you could create a special session for that page and set the cookie to expire after 48 hours. you will need to create some cookie setting code and getting code to make sure that the cookie is not reset to visit plus 48 hours each time (unless that is what you want).

something like this perhaps

Code:
session_name('48hrRight');
$lifeTime = 48*60*60;
session_set_cookie_params($lifeTime);
session_start();
$curValues = session_get_cookie_params;
if (!empty($curValues) && $curValues['lifeTime'] < $lifeTime){
 setcookie(session_name(), $_COOKIE[session_name()], time()+$lifeTime, "/");
}
if ($lifeTime < 0){ 
 $_SESSION['can_download'] = false; 
 die('time out');
}
if ($_SESSION['can_downloand'] == true) { //allow the page to come up}

i'm sure it could be hacked and you could certainly improve the security by causing the session cache to expire and be garbage collected in the same time scale. take a look at for more info

have a look in the faqs for a database driven session management plugin written by sleipnir214.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top