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

Date Function

Status
Not open for further replies.

itechC

Programmer
Joined
Feb 13, 2003
Messages
71
Location
CA
Hi all,

I need to display the current date everytime a user clicks to download a certain file. Example if the user downloads a pdf on sept 3 then again on sept 8 i would like to display the last time the user viewed that pdf.

Thanks
 
When they visit a page, check the cookies array for the last date they visited and use that if it's there. Then write the current date to a cookie, so it's available for step 1 next time.
 
Keep in mind that the only way this is possible is to write a PHP script that streams out the file.

If your link looks like &quot;<a href=&quot; File</a>&quot;, it won't work because PHP will never be involved in the retrieval.

You'll have to write a PHP script that sends the file. You're link would look something like &quot;<a href=&quot; File</a>&quot;


Also keep in mind that the only way to do this deterministically is to be able to uniquely identify the user.

If you require a user login, you can use PHP code to fetch the last download date. I'd store the data in a MySQL database.

If you do not require user logins, there is no way to deterministically identify a particular user. Cookies are a partial solution -- but a user can always clear his cookie store.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
I was thinking more of him showing the date on the page next to the link or wherever, just before the user downloads it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top