Disbaling Leaving the Page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sake
    New Member
    • Jan 2007
    • 46

    Disbaling Leaving the Page

    I don't mean disabling leaving the site entirely, forcing the user to remain at my god forsaken mess for the rest of eternity. But instead just disabling going to any other part of my site (until certain requirements are met). Is there any way to do this securely without putting a check for the requirements at the beginning of each page?

    -Sake
  • harshmaul
    Recognized Expert Contributor
    • Jul 2007
    • 490

    #2
    Depending on the requirements you could fill in the session with different values until all of the requirements are met.

    For example if you require three pages to be visited before going on to another page,.. increment a session variable $_SESSION['pagecount'] by one. and then on the other page check this value.

    There is probably a better idea involving signing up and checking database values. but it depends on what the criteria are.

    Comment

    • sake
      New Member
      • Jan 2007
      • 46

      #3
      well its more or less a puzzle type of thing, so you have to win the puzzle before continuing anywhere. I already have the code to check whether or not they've won, and i guess i could just check for that on each page.

      Comment

      • harshmaul
        Recognized Expert Contributor
        • Jul 2007
        • 490

        #4
        As soon as you work out whether they've won or not stick a variable in the session or cookies stating that.

        Or if they have to log in to do the puzzle assign a value somwhere (depending on your DB structure) to say that the puzzle was done.

        the session approach...

        put this on pages you want to lock if the user hasn't completed the puzzle.
        Code:
        <?php
        session_start();
        if (!IsSet($_SESSION['puzzle'])){
        	header("location:index.php");
        }
        ?>
        Assign the value similar to this...
        Code:
        $_SESSION['puzzle'] = 1;

        Comment

        Working...