Changing visibility of image through session (or something)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
herlaar
Forum Newbie
Posts: 1
Joined: Wed Jul 10, 2002 2:37 pm
Location: Breda, The Netherlands

Changing visibility of image through session (or something)

Post by herlaar »

I'm trying to get the following to work. I have an image visible on a site. The visibility of the image is counted everytime someone sees it. Also when a person reloads the page.

The image is called with a Image tag in HTML through an php-script (like <img src=script.php?illus=car>.

What I try to accomplish is that this image is only made visible the first time the page is loaded. So that when the same user reloads the page he won't see the image anymore.

I'm thinking of using session_start, but I'm not sure how to integrate this. Anyone has a clue?
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

sounds like a job for google to me. Sessions definitely are the way to go, and there are tons of tutorials on them to be found. Check out phpcompelete.com, i know they have one.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Yeah, but shamefully, that tutorial is out of date. =)

Easily, you can do something like this:

Code: Select all

<?php
session_start();
if ( isset($_SESSION&#1111;'viewPic']) ) &#123; 
    $_SESSION&#1111;'viewPic'] = false;
&#125; else &#123;
    $_SESSION&#1111;'viewPic'] = true;
&#125;

if ( $_SESSION&#1111;'viewPic'] ) &#123; 
    echo ''<img src="script.php?illus=car">';
&#125;

?>
Something like that should work.
Post Reply