Solved

CGI Link Question

Posted on 2003-02-25
13
189 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
Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

 

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using a hta file with MSSQL agent to schedule a script job 4 65
Logon script fails 23 69
PowerShell logging 1 33
Powershell Code 3 53
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

737 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