PHP Login with Session

0
290

Hello there. In this tutorial you will learn on how to login with session in PHP as well as removing your session variables as you logout.

First we must need to create a database and tables.

I just created a database “demo” and a table “tbl_users” with fields “id”, “user_fullname”, “username”, and “password”.

We will only need 3 PHP files: login.php, index.php, and logout.php.

A session is started with a session_start() function.

Session variables are set with the PHP global variable $_SESSION.

Let us now create the first file (login.php).

 

Let us create the second file (index.php). In this file we will just put a logout button and display the data of the user.

 

And for the last file (logout.php).

 

That’s it for PHP login with session. Godbless.

Download “PHP-Login-with-Session.zip” PHP-Login-with-Session.zip – Downloaded 28 times – 2 KB