Sessions and individual ids

Hi all,

I have a simple $_SESSION variable that prevents multiple views on a page. The problem is the page is a template and so even if the particular story displayed is different the session assumes it has already viewed it. Is their any way to set individual session for each story by their id, so that one user can look at multiple stories without my session checker preventing the view count from being incremented.

Here is the code I have at the top of the story.html.php template:

<?php session_start();
if(empty($_SESSION['viewed'])){
  $_SESSION['viewed'] = true;
  echo "hey";
  $SQL = "UPDATE story SET views = views + 1 WHERE id = '$id'";;
  mysqli_query($link, $SQL);
}else{
  echo "already viewed";
}
?>

Sure

Make your session variable an array, and populate the array with each individual page ID each time a page is viewed.

Now when you check the session variable just search the array for the page ID, if its there the page has already been viewed, if not you add the ID to the array and show the page.

:smiley:

How might I go about that?

Sorry but I suck at PHP