daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [root@localhost auth]# cat protected.php
  2. <?php
  3. //tratar erros
  4. set_time_limit(30);
  5. error_reporting(E_ALL);
  6. ini_set('error_reporting', E_ALL);
  7. ini_set('display_errors',1);
  8.  
  9. //initialize session
  10. session_start();
  11. echo '<br>access'.$_SESSION['access'].'<br>';
  12. if(!isset($_SESSION['user'])) {
  13.     //  usuario nao esta logado, redireciona para login.php
  14.     header("Location: login.php");
  15.     die();
  16. }
  17.  
  18. if($_SESSION['access'] != 2) {
  19.     // outro exemplo...
  20.     // usuario esta logado, como parar.
  21.     die("Access Denied");
  22. }
  23. ?>
  24.  
  25. <p>Bem-Vindo <?= $_SESSION['user'] ?>!</p>
  26.  
  27. <p><strong>Teste!</strong></p>
  28.  
  29. <p><a href="login.php?out=1">Logout</a></p>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top