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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time sensitive hyperlink. Is it possable ?

Status
Not open for further replies.

Smoothas

IS-IT--Management
May 1, 2002
93
GB
Hello,

I'm trying to write a webpage that will create a time sensitive hyperlink to a document.
Once the time is up, then access to that document via that link is lost ( possably with an error message page instead of the document ).
A new link can be requested to the same file ( by going thought the process on the page again ), but this will expire after a set amount of time ( say, 36 hours )

I've played around with a few ideas, but not been very successful.

Any ideas how I might accomplish this?

Thanks
 
Using server-side scripting (PHP, ASP, ASP.NET, Cold Fusion, JSP, etc.) to indicate the initial time on the page for Javascript to work with, you can make a link that will expire whenever you want. However, anyone with Javascript turned off wouldn't be limited to your time out period.

Lee
 
The link would still be visible in the source, though, so someone could access the file directly using that.

Lee
 
I assumed server side was the correct termninology to use.
if not, then please disregard this part of the question.

I just wanted to know if it was possable to create a time sensitive hyperlink based on when and indiviual clicks a button .
Once the specifed time is up, the link points to a "sorry. Timed out" webpage, but a new hyperlink to the file / webpage etc can be produced by going though the procedure webpage procedure again.

IF his is possable, is it possable using javascript, and if so, how would I go about it.
If it's not possable via javascript, what would be the best language to attempt it in?

Thanks
 
Possible yes, secure no.

You can create a cookie that holds the time the link was initially made available and set the cookie to expire whenever you want. Look for the cookie each time if its set and not expired then you can show the link.

You can make it so if JS is not turned on, or the time has expired, it wont write out the link.

However this is still less than secure because anybody can look at your source code and find the link there.

a server side solution using PHP or ASP or coldfusion maybe be a better alternative because you can inhibit the link from ever reaching the client.

Still for a JS solution:

Set the cookie:

document.cookie='timedcookie=allow; expires=Thu, 18 Oct
2009 2:00:00 UTC; path=/';

Then check for the existence of the cookie before showing the link

Here are some good examples of how to set the cookie.


for a server side solution:

forum434
forum333
forum855





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Phil, you gave me an idea how to do this and still make it secure from MOST people. If you put the link in a cookie along with the expiration time, then you could read the cookie to get the link and put it in a variable, then write that to the page dynamically with either document.write when the page loads, or after the page loads with document.getElementById.

But you're correct that you can't do this securely client side.

How about setting a meta refresh to go to the procedure web page after the time limit?

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top