PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Dave Smith   PHP Secret URL Path   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Usage Example
Class: PHP Secret URL Path
Authorize access based on user click sequence
Author: By
Last change: Added text to clarify default path sequence
Date: 7 years ago
Size: 1,210 bytes


Class file image Download
secretPath class
version 1.0 10/21/2016

Authorize access based on the sequence of user clicks

//start session - sequence saved in $_SESSION super global

//include class source

//instantiate the class or define class object from saved data
if( empty($_SESSION['secpth']) ){
$path = array(1,2,3,2,2);
$secpth = new secretPath('link',$path);
$secpth = unserialize($_SESSION['secpth']);

//test user click sequence and send to secret page if sequence completed
if( $secpth->validatePath() === true ){
//it is important to save the class object before re-directing
$_SESSION['secpth'] = serialize($secpth);
header('location: secret.php');

//save class object to session
$_SESSION['secpth'] = serialize($secpth);

        <title>Secret Path Example</title>
        Default secret path is link: 1,2,3,2,2<br><br>
        <a href="example.php?link=1">Link 1</a><br>
        <a href="example.php?link=2">Link 2</a><br>
        <a href="example.php?link=3">Link 3</a><br>