Welcome Guest, Not a member yet? Register   Sign In
What is the best practice for age verification landing page in CI?
#1

[eluser]term25[/eluser]
My webpage is for adults only and therefor I need a landing page where you will have two buttons (1st with I want to enter and 2nd I wnat to leave).

After clicking on the first button the user will be redirected to the main page.

What is the best practice to achieve something like that in CodeIgniter?

#2

[eluser]term25[/eluser]
I have found this solution, but I have problem with implementation into CodeIgniter:

Here's what you need... a 2-script solution (one is an include, one is a verification page).

verify.php

PHP:

Code:
<?php
session_start();
if ($_REQUEST["over18"] == 1) {
    $_SESSION["over18"] = 1;
    header("Location: " . $_REQUEST["redirect"]);
}
?>
<html>
    <head>
        <title>Verify Your Age</title>
    </head>
    <body>
        <a href="verify.php?over18=1&redirect;=&lt;?=$redirect?&gt;">I am over 18</a> |  
        <a href="http://www.google.com/">Get me out of here!</a>
    &lt;/body&gt;
&lt;/html&gt;
require_verification.php

PHP:

Code:
&lt;?php
session_start();
if ($_SESSION["over18"] != 1) {
    header("Location: verify.php?redirect=" . $PHP_SELF);
}
?&gt;

content_page.php

(Make sure to include the require_verification as the first line of any containing pages to prevent header synchronization exceptions.)

PHP:

Code:
&lt;?php include("require_verification.php");  ?&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;Sensitive Content&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        <img src="something_sensitive.jpg" alt="EEK!!!" />
    &lt;/body&gt;
&lt;/html&gt;
&lt;/html&gt;
#3

[eluser]weboap[/eluser]
you can set your default controller in the routes.php
something like
Code:
$route['default_controller'] = "verification";

to the verification controller (call the file verification) withing it you can use sessions
in the index load a view that will have your links

Code:
&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;Verify Your Age&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        <a href="http://mysite.com/verification/check">I am over 18</a> |  
        <a href="http://www.google.com/">Get me out of here!</a>
    &lt;/body&gt;
&lt;/html&gt;



in the verification controller you can create the function
Code:
.....
public function check(){

$newdata = array(
                   'over18'  => true,
                   'passcheck'     => true
               );

$this->session->set_userdata($newdata);

//then redirect the user to the real landing page

redirect('/home', 'location', 301);

}


then in the constructor of every controller you check if

Code:
$over18 = false;
$passcheck = false;

$over18 = $this->session->userdata('over18');
//making sure the user didn't land on the page from outside.

$passcheck = $this->session->userdata('passcheck');

if(!$passcheck){
//take him to verify
redirect('/verification', 'location', 301);
}


if(!$over18){

header("Location: http://google.com, TRUE, 302");  

}


well this is a quick solution, somebody may have better. good luck.
#4

[eluser]term25[/eluser]
Thanks, for your solution. In the end I ended up with using the database table for this task, becaouse it turned out that I need to store also the IP and date when the yes button was clicked on the verify page and the actual address where the user want to go (e.g. he want to go to something.com/product/2356 this address is saved too. so I saved his address no matter what in the db every time he enters every page, then there is a check script if the date is less than 24 hours, if not he is redirected to the verify page and if he click on yes, the date is rewritten in the database and his IP has another 24hours Wink. He do not have to be registered to enter my page so this is the only way I know of that can achieve something like I wanted.




Theme © iAndrew 2016 - Forum software by © MyBB