Actually, it should be quite easy with .htaccess. It's just that it isn't guaranteed you'd be able to block/allow exactly who you want. If you store all your images in one folder, then it would look something like this:
Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://yoursitename\.x10hosting\.com/ [NC]
RewriteRule .* - [F]
However, the problem with this is that it relies on http_referer, which isn't reliable itself. You could include a line to allow requests which come from users with no referer, but then hotlinked requests from these users would also be accepted.
So, if you just want to allow logged in users to view the images in this folder, then I would deny all access to the folder and have the images linked through a script. The script could then make sure the user is logged in, and then respond with the requested image if they are. Something like this:
HTML:
Code:
<img src="getimage.php?img=someimage.png" alt="Some Image" />
getimage.php:
PHP:
if (isset($_SESSION['user_id'], $_GET['img'])) {
$img = 'images/' . $_GET['img'];
if (file_exists($img)) {
$type = substr($img, strrpos($img, '.') + 1);
switch ($type) {
case 'jpg':
case 'jpeg':
$type = 'image/jpeg';
break;
case 'png':
$type = 'image/png';
break;
case 'gif':
$type = 'image/gif';
break;
default:
exit(0);
}
header("Content-type: $type");
readfile($img);
}
}