Posted By

daveismyname on 09/27/09


Tagged

login check


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

ziggyscoope
bayxsonic
benediktvaldez


Login checker Functions


 / Published in: PHP
 

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

  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  

You need to login to post a comment.