Skip to content

Instantly share code, notes, and snippets.

@robhurring
Created May 6, 2010 19:07
Show Gist options
  • Save robhurring/392570 to your computer and use it in GitHub Desktop.
Save robhurring/392570 to your computer and use it in GitHub Desktop.
<?php
session_start();
// Check for the session[user_id] param to see if the user is logged in
if(!isset($_SESSION['user_id']))
header('location:login.php');
echo 'This is my secret page.'
// curl http://localhost/insecure.php
// => "This is my secret page."
?>
<?php
session_start();
// Check for the session[user_id] param to see if the user is logged in
if(!isset($_SESSION['user_id']))
{
header('location:login.php');
echo 'Denied.';
exit();
}
echo 'This is my secret page.'
// curl http://localhost/less_insecure.php.php
// => "Denied."
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment