PHP code for anti hotlinking

php

Solution

Image hotlinking is usually detected by referer, but it won't work when:

- user has turned off referer sending in his browser (I have this for privacy purposes)

- page is viewed via HTTPS (browser shouldn't send referer data).

You'll block your actual users from viewing images.

Consider using sessions / cookies when dealing with this problem. You'll have to pass every image via php script then.

Problem

In our sites we are doing a image protection section. So as a part of image protection we need provide antihotlinking for images.In our site we are showing the image using a generated url. For example in our site the image source is like: `image_file.php?type=image&w=10&h=10&i=12` (this only a fake url for example purpose). So using this url we need to show image in our site and at the same time want to prevent it from hot linking is there any way for prevent hotlinking?

Original source

Related problems