Ok i'm using a page count to count the number of time profile.php is accessed by users. If they are not logged in they can only view 5 users profiles.
Each profile has an extension of profile.php e.g. profile.php?id=1 or id=2 etc.
The page count works fine, basically if a user tries to click on more than 5 profiles it will redirect them to the limit.php page which tells the user they have reached their limit an to login in to view more.
I have set it to exclude a few profiles as listed below.
basically what the problem is, if the user clicks on the excluded profiles such as 99999 or 99998 it wont redirect the user to the limit.php page. This is fine because i want it to exclude these profiles, however, if the user clicks on another profile such as 1 or 8 etc in between and the user tried to revisit 99999 or 99998 then it wont let them and redirects them?
Can anyone show me how i can edit the script to still allow users to access profiles 99999 or 99998 even after or during them visiting other profiles without it redirecting them?
Hope this is clear. Thanks
<?php
!session_id() ? session_start() : null;
if(!isset($_SESSION['page_access_count'])){
$_SESSION['page_access_count'] = 1;
}elseif($_SESSION['page_access_count'] >= 6){
// redirect to signup page
header('Location: limit.php');
exit;
}
$free_profiles = array(99999,99998,99997,99996,99995,99994,99993); // array of profile IDs to exclude
if (! in_array($_GET['id'], $free_profiles)) {
$_SESSION['page_access_count']++;
}
?>