Coder Social home page Coder Social logo

masif786 / php-secure-session-database-login Goto Github PK

View Code? Open in Web Editor NEW

This project forked from seanhweb/php-secure-session-database-login

0.0 2.0 0.0 53 KB

A cookie cutter template to secure pages of a site behind a username and password.

Home Page: https://seanhweb.com/secure_demo

PHP 100.00%

php-secure-session-database-login's Introduction

PHP-Secure-Session-Database-Login

This project was designed as a base template to secure information behind a login page of a website.

User Configuration Options

Config options are held in config.php.

  • Web Root
    • Where a user is taken before logging in.
  • Post Login
    • Where a user taken upon a successful login attempt.
  • Session Duration
    • How long it takes for a user to be asked to log in again.

Database

This library uses two tables. Sessions, and users. The SQL file is available above.

Sample Usage

Logging In

On your index.php, you would create a log in form. The action, however you choose to execute it, is as follows.

$user = new user; 
$user->login($username,$password);

The login function checks the database for the username and password. If all is well, it then runs the "begin_database_session" function, which redirects them to the post login page in your config.php.

Secure Pages

For every page you would like to be secure, include the following code.

$session = new session;
$session->update_session();

When this code is executed, it checks the following. - Has it been longer than the defined session time? - Is there a valid user agent string? - Is the session unique ID the same as the servers? If any of these are false, it runs the "destroy session" function and asks the user to login again.

php-secure-session-database-login's People

Contributors

seanhweb avatar

Watchers

James Cloos avatar Muhammad Asif avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.