Solved

CGI Link Question

Posted on 2003-02-25
13
190 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +1
13 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

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 50 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 50 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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
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…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

729 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