简体   繁体   中英

How to hide images from unregistered users

I made a website to share pictures like films but i have problems with privacy. When u create a photo film u can share its url with people but people who are not logged in my website they still can watch my film http://thephotofilm.com/films/1002947

SELECT path FROM images WHERE img_id=(id)
if($type=="ole")
$type=1;
else
$type=1;
if(!is_numeric($imageIndex) || $imageIndex<0)
invalidImage();

If user is not logged in display a blank picture

Thanks in advace!

you do it with $_session['username'] .

  if(isset($_session['username'])){   //change this session to your session name.
      echo 'show image here';
     }
     else{
      echo 'tell him wtf are you doing here';
      }

I would use a session variable to check against. If the user has a valid session, show the image. If not, do not show the image.

Something like this:

if ($_SESSION['my-session-var']
{
    echo '<img src="my-image.jpg" />';
}
else
{
    echo '<p>You gotta log in first, ya \'doofis!</p>';
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM