?
Solved

CGI Link Question

Posted on 2003-02-25
13
Medium Priority
?
194 Views
Last Modified: 2013-12-25
Hello,

Is there are way for me to have a link be invalid after a certain amount of time?  Example, if I have a download link that I have for a user, and I want that link to be valid for one hour, how do I do this?  Or can I?  Please provide an example.

Thanks,
aj85
0
Comment
Question by:aj85
  • 4
  • 3
  • 3
  • +1
11 Comments
 

Expert Comment

by:amitabhrai
ID: 8018773
You can create two overlapping <DIV>. One containing the link  and other containing the exact text of the link without the link. Make the <DIV> with link visible first. Using javascript settimeout function, make this <DIV> invisible and the other <DIV> visible after desired amount of time. This should do the trick.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 8018901
amitabhrai, is there any reason this trick should work?
I don't use JavaScript :-]]

aj85, depending on you web-server you can set such restrictions in .htaccess
IMHO this is overkill for such a simple task 'cause you need to edit the .htaccess file twice

Why not simply starting am at which deletes the file?
0
 

Expert Comment

by:amitabhrai
ID: 8018997
ahoffmann ,
 I probably misunderstood the original question. I was under impression that the user has the page opened for say 30 minutes and after that the link should be disabled. But now I guess the requirement is to not allow the user to download after specific time.
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 

Expert Comment

by:amitabhrai
ID: 8019010
aj85,
  It would be helpful if you can specify what exactly you mean by "link be invalid".
Do uou  want the user to see the link?
What should happen if he clicks on it?
0
 

Author Comment

by:aj85
ID: 8021055

Hello,

Thanks for both of your replies.  What I mean by "link be invalid" is to have the link not be accessible by the user after 30 minutes or an hour or what ever time is set.  You wrote "But now I guess the requirement is to not allow the user to download after specific time."  This is correct.  That is what I want to do with the script.  Let me know if you have anymore questions.  Please provide example.

Thanks,
aj85
0
 

Author Comment

by:aj85
ID: 8021088
Follow up, to add a little more clearity.  What I want to happen is that when a user enters their required information, and clicks "submit" for example.  Then are taken to the download page.  I want that link to the download page to valid for only an hour.  I hope this helps.

Thanks again,
aj85
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 200 total points
ID: 8023648
the link (URL) given to the user shuld be a link to a cgi (program, script, whatever).
This CGI checks the time when called the first time, provides the link for download to the user (using redirect or whatever), and then simply executes something like:
   echo "rm /path/to/file"|at now + 1 hour
0
 

Author Comment

by:aj85
ID: 8025069
Ok, I see.  I will try this and get back with you shortly.  Thanks for the quick reply.

aj85
0
 

Expert Comment

by:amitabhrai
ID: 8025599
You can also try this:

1. when form is submitted set a cookie valid for 1 hour.
2. on download link, check for the cookie. If cookie not
  found then send error message back to user.
3. If cookie found then redirect it to download page.

I personnaly don't like to use "rm" command in CGI. It also makes the application system dependent.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 8027613
what or who restricts me to accept the cookie and redefine it as I like? :-]]
Cookie, same as JavaScript, totally unreliable and unsave attempt.
0
 
LVL 2

Assisted Solution

by:martianism
martianism earned 200 total points
ID: 8185849
I would say that the cookie option seems the best way to track a user around your site.  Cookies are not inherintly insecure and are not inherintly bad,  it is just in the early days of ebiz they were over used to hold stupid data like credit card numbers and so were easily stolen.

As long as you explain to the user what the cookie is for before setting it (maybe do this client side with a pop-up yes / no type box on first use), I cannot see any great issue.

Other then that you only reliale way is to user a username password based system to track users movements on the site, are users already required to register?  If so then you could use this route instead.

Unless anyone has a good way of handleing it?

--
Martianism
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question