Skip to content

A simple and raw PHP class to manage user login, logout and account creation.

Notifications You must be signed in to change notification settings

adeyinkakoya/users-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

users-manager

A simple and raw PHP class to manage user login, logout and account creation.

If you don't have already setup the database table you can use this example snippet

CREATE TABLE `testdb`.`users` ( `id` INT(10) NOT NULL AUTO_INCREMENT , `email` VARCHAR(50) NOT NULL , `username` VARCHAR(20) NOT NULL , `password` VARCHAR(20) NOT NULL , `session_code` VARCHAR(100) NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;

Account creation

This method will not manage the user input validation/sanitization, it will only check the database to verify if an email address or an username was already taken from someone, so don't forget to sanitize or validate your input first. The password will be hashed using the php's built in password_hash() function.

$obj = new User($db);

$obj->createUser($email,$username,$password);

Login

This method will try to setup the $_SESSION variable by assigning to it the user id, the username and a random generated session code who it will be stored inside the users table and removed every time an user will do the logout.

$obj->loginUser($username,$password);

Logout

$obj->logoutUser($_SESSION['id']); 

About

A simple and raw PHP class to manage user login, logout and account creation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages