Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    help with session/include

    Im wanting to count each page a visitor goes to including if the same page is visited more than once ie; if MR X vivits INDEX.php then CONTACTS.php then back to INDEX.php I need it to count as 3 page visits. I then need a different .php page to display for each page visited. i have the php files loaded as fb00.php, fb01.php , fbo2.php , fb03.php ect ect. heres the code im using
    Code:
    <?php 
    if (isset($_SESSION['hit']))
    $_SESSION['hit']++; 
    else 
    $_SESSION['hit']=0; 
    $try_file='fb0'.$_SESSION['hit'].'.php'; 
    if (file_exists($try_file)) 
    include $try_file; 
    else 
    { 
    $_SESSION['hit']=0; 
    } 
    ?>
    It works but only displays fb00.php and I need this to change with each new page
    Thanks for any help

    P.S. before anyone asks I need this because Im part of a banner exchange that requires a new banner to be displayed on each page. If you have the same banner on each page you get credited with 1 visit even if the visitor goes to 10 pages. If you have different banner on each page you will be credited with 10 visits rather than 1

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Are you using session_start()? You didn't specifically mention it and it's not in this code sample.
    Are you a Help Vampire?

  • #3
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    yes I have session start on a previous page

  • #4
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    On a previous page? The function is required on every page where you want to use sessions. See the man page and the others on the site associated with sessions.

    EDIT: The man page doesn't provide enough information. Try a google for "php session_start". I'd provide some useful results, but my DNS doesn't seem to want me to see half of the interwebs at the moment.
    Last edited by tomws; 03-08-2009 at 07:48 AM.
    Are you a Help Vampire?

  • Users who have thanked tomws for this post:

    textahead (03-08-2009)

  • #5
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for all your help. Ive figured it out. didnt realise you needed session_start(); on each page Thanks lots Cheers


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •