Login checker Functions


/ Published in: PHP
Save to your folder(s)

2 login functions that check if a user is logged in by checking is a session is equal to true that would have been set on login.

If not logged in the redirect to login.php


Copy this code and paste it in your HTML
  1. function logged_in() {
  2. if($_SESSION['authorized'] == true) {
  3. return true;
  4. } else {
  5. return false;
  6. }
  7.  
  8. }
  9. function login_required() {
  10. if(logged_in()) {
  11. return true;
  12. } else {
  13. header('Location: login.php');
  14. }
  15.  
  16. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.