Page 1 of 1

Changing visibility of image through session (or something)

Posted: Wed Jul 10, 2002 2:37 pm
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?

Posted: Wed Jul 10, 2002 3:38 pm
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.

Posted: Wed Jul 10, 2002 6:36 pm
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.