Hello to all of you developers,
I wanted to make a web page in php that can only be accessed through a generated URL , that webpage can only be accessible 3 days with that generated URL. After that , the user can no longer access that page.
What is your best advice to do that?
Thank you very much in advance.
EDIT : Thank you very much for all of your answers and consideration into this subject , surely it helped me a lot.
Advertisement
Answer
A simple method is to use a JWT-like method. You put a private key on your server. Your server generate url like http://my-url?expireAt=20210401&sign=XXXXXX
, where the sign
is the signature. Then, when the user visits this page, the server not only check whether current time is before expireAt time, and also check the signature to see whether the paramters is generated by the server (or by a bad user himself).
P.S. You may need some basic knowledge in cryptography to understand the answer. It is a very commonly used idea 🙂
EDIT:
Here is an example – how AWS shares a file with a presigned url. https://docs.aws.amazon.com/AmazonS3/latest/userguide/ShareObjectPreSignedURL.html
When you create a presigned URL for your object, you must provide … expiration date and time. The presigned URLs are valid only for the specified duration.
That’s exactly what you want 🙂