如何生成在PHP中获得3次权限的自动URL?

问题描述:

I would like to generate a URL which will have a unique code tail at the and only will be used 3 times. After accessing 3 times from the link. the url will expire. How can I do this? Basically I think I need to create a database and map the permission for the url and have acountdown number? is there any better way of doing this? An example of this is in facebook you can just copy and send a link to the people to see your pictures without going online or being your friends. ?

我想生成一个URL,该URL将具有唯一的代码尾部,并且仅使用3次。 从链接访问3次后。 网址将过期。 我怎么能这样做? 基本上我认为我需要创建一个数据库并映射该URL的权限并具有减少数量? 这有什么更好的方法吗? 这方面的一个例子是在Facebook,您只需复制并发送链接给人们,无需上网或成为您的朋友即可查看您的照片。 ? p> div>

You've already thought of your own solution! There is no easier way.

Lets have a look at what you need:

  1. An url referring to a specific page (or an image in your case)
  2. A limit of times your url can be visited
  3. A count of the amount of visits

All 3 requirements seem to need a database. You can use an alternative database, such as local xml files but that would be way more work than using a mysql database for instance.