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 6 of 6
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,649
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Always start at index

    With pages all over the internet, my users need to come into my site on the index and not the middle. My $_SESSION starts on the index...What would you guys recommend? Example? Thanks
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    If you mean that people should only come to your site through the front page then you can easily do that using sessions.

    On the front page just add a value to your session indicating they have visited the front page

    PHP Code:
    <?php
    session_start
    ();
    $_SESSION['frontPage'] = "true";
    ?>
    Then on every page just check to see if that session variable exists and if it doesn't then send them to the front page:

    PHP Code:
    <?php
    session_start
    ();
    if(!isset(
    $_SESSION['frontPage']))
        
    header("Location: index.php");
    ?>
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,649
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ok...Thanks
    Few more q's:
    Shouldn't that if(!isset($_SESSION['frontPage'])) have a semi-colon on the end of it?
    Also, my real index is up a level. Should I use header("Location: ../index.php"); or the full URL header("Location: http://site.com"); ?
    This is for pages found in search engines.
    Thanks
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Shouldn't that if(!isset($_SESSION['frontPage'])) have a semi-colon on the end of it?
    No Underneath the if statement is the condition if the session is set

    Should I use header("Location: ../index.php"); or the full URL header("Location: http://site.com"); ?
    I don't think there's any difference, apart from a few extra characters in the script

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Better use an absolute address in the header() command, IIRC this is demanded by the HTTP specs. So using http://www.site.tld would always work, while the relative URLs are at the mercy of the client. Most browsers do resolve these relative locations though, but I can't speak for the googlebot.
    De gustibus non est disputandum.

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,649
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Gotcha...Thanks all.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">


  •  

    Posting Permissions

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