duanqiao2006 2012-04-14 14:08
浏览 114
已采纳

通过IP限制访问,cookie? - 更好的解决方案?

I'm using PHP & MySQL to limit access of downloads to unregistered users.

The only options I see to do this are cookies and/or IP address.

Cookies is not a good solution, seeing as it's important that a user can't reset their download count by deleting their cookies - as the idea is that they pay if their usage is above a certain level.

That leaves me with restricting the access by recording the IP address in PHP and inserting it into the MySQL database. The problem with this traditionally is that some people are on dynamic/shared IPs, and so the count will mean nothing to them, and could even stop other potential customers from having their free downloads.

But then again, virtually all of my sales are from Western countries, and it seems that most people in the West are now on a static IP address... is this correct?

What would be the best solution for this dilemma? Any thoughts?

  • 写回答

3条回答 默认 最新

  • doubaoxue5788 2012-04-14 15:22
    关注

    You can better identify a unique user by using a mix of tactics then just one tactic. Combining the IP address, a cookie and the browser's user agent can give you a unique key for a client. I also recommend embedding a JavaScript snippet that sends OS, Screen size, etc.. etc.. to the server to be associated with the unique user.

    You then use a step down approach to regulate access. User's who provide you all the access to the above information, can download the files to their limits. User's who restrict cookies, disable javascript get less access to the files. And you fall back on the IP as being simple a unique ID for the user. If they are on a shared network, then tough for them they should enable cookies.

    For people with rolling IP addresses, disabled cookies and disabled Javascript. There isn't really much you can do, but they represent a small percentage of users.

    A cookie isn't a good way to ID someone, cause they can delete it, but it will save you some DB execution for looking up just the IP and user agent. So it's more of speed thing.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀