M
M
MihaUrakov2020-02-24 20:30:25
PHP
MihaUrakov, 2020-02-24 20:30:25

How to make a self-deleting link live in time?

Hello!

Tell me how to make the link live for a specific time, from the moment of entry, and the time was fixed according to the time spent on it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nokimaro, 2020-02-24
@nokimaro

Since the MySQL tag is worth it, I assume that the links are stored in the database?
So for each link you need to make a column with the time the link was created and the time of the first click (visit) on it.
Link creation time can be used if it is necessary, in principle, to limit the link in time, regardless of whether it was visited or not.
Default entry time null. When opening a link, we look at this value, on the first visit we fill in the current date, on repeated clicks we compare the date and current time.
If more than a certain time has passed, we consider that the link has been deleted.
You can also actually delete links with an expired date from the database, while links where the visit date nullis considered not visited and are not deleted. It already depends on your requirements.

N
N0zzy, 2020-02-25
@N0zzy

Create links on time? Probably not a link, but the provision of content in accordance with the lifespan?
If yes, then create a token and lifetime. When prompted, check the deadline. If the deadline has passed, then the error 404.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question