Question: My problem is when you use for exemple :

```
<img src="/img.jpg" />

```

the src has to be an image and the image has to be accessible to the person. I want to be able to control the access to those image (if the user is logged for example). IF the person has not access to the image, he can't access it. My script that controls the access to an image is a php file.

I know .htaccess can limit access to ressources, but I need to valid in the php file. Is there a way to do this or to load the image with javascript (using ajax request) and changing the source of the image to the location of the image in the temp folder?

Answer: 
You can do this with PHP ... see [imagejpeg](http://uk3.php.net/imagejpeg) for an example ... you then have the `img` as follows :

```
<img src="/myfile.php" />

```

or use your PHP file to grab an image and output it using :

```
header('Content-Type: image/jpg');
echo file_get_contents("yourimage.jpg");

```
You can ceep user\_login\_status in your $\_SESSION, and on a view part check it

```
<?if ($_SESSION['user_status'] == 'login'){?>
  <img src="/img.jpg" />
<?}else{?>
  // some stuff instead of <img/>
<?}?>

```