In my earlier tutorial, I’ve proven you How to Set up Cookie. This tutorial gives you an thought on the right way to use the saved cookie to login and I’ve added a “logout” operate that destroys each session and cookie.
First, we will create a database that incorporates our information.
1. Open phpMyAdmin.
2. Click on databases, create a database and title it as “cookie”.
3. After making a database, click on the SQL and paste the beneath code. See picture beneath for detailed instruction.
Subsequent, we insert customers into our database. This can be our reference after we login.
1. Click on the database the we created earlier.
2. Click on SQL and paste the code beneath.
Subsequent is to create our login type. On this type, I’ve added a code that if ever there is a cookie saved, it should present within the login inputs. To create the shape, open your HTML code editor and paste the code beneath after the tag. We title this as “index.php”.
Subsequent step is creating our login script. We title this script as “login.php”.
Final is our logout script. This script destroys each our session and cookie then redirect us again to our login web page. We title the script as “https://www.sourcecodester.com/logout.php”.