Skip to content

Password Protect Files using a PHP login page (with sessions and logging)

Notifications You must be signed in to change notification settings

JKJameson/pwprotect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

pwprotect

Password Protect Files using a PHP login page

An alternative to Apache's Password Protection for Directories.

  • Uses PHP sessions
  • Logs failed attempts to PHP error log
  • Logs successful logins to PHP error log

Usage

At the top of your script:

<?php
require 'pwprotect.php';

# Your code goes here...
echo "You are logged in as {$_SESSION['pwprotect']['user']}<br>\n";
  • The username of the logged in user is provided by the variable $_SESSION['pwprotect']['user']
  • Logout a session by navigating to pwprotect.php?logout
  • Optionally, redirect to a custom URL by passing an urlencoded string like this pwprotect.php?logout=https%3A%2F%2Fgoogle.com (which would redirect to https://google.com

About

Password Protect Files using a PHP login page (with sessions and logging)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages