thejoker
thejoker

Reputation: 159

How to only allow images to be accessed by logged in users

Currently using Codeigniter/PHP and IIS 7

I have currently looked at "hotlinking" but that only protects images from being put onto other web sites. It doesn't stop the end user from directly pasting the image URL into the address bar and accessing the image whilst not being logged in.

I am not too sure what the best way is to approach this problem. How can you protect images so that it can only be accessed by logged in users?

Thank you.

Upvotes: 1

Views: 1611

Answers (3)

Dum
Dum

Reputation: 1501

There are perfomance issues in the above answer. You can rename the folder that containing images every hour / day .... Ex

images/a8s7d5r7w9/33229.png to images/g2j3s3l1p2t/33229.png

Upvotes: 0

Rana
Rana

Reputation: 6154

Best approach would be, if you stop using real url of images on the whole site and always retrieve the images via a php script(controller function) that could help you checking user authentication and other staffs like resize/crop/cache etc as well.

In that case, you can use any url even in root base, which isn't known to outside world at all.

Upvotes: 0

Naftali
Naftali

Reputation: 146310

Put the images somewhere outside the webroot of the site.

Have a php script that gets the images and displays the images only when logged in.

Upvotes: 1

Related Questions