PHP login script using session and session variables
P粉726133917
2023-08-21 19:01:51
<p>I've just finished a complete login and registration system in PHP, but my problem is that I haven't used any sessions yet. I'm new to PHP and have never used sessions before. What I want to do is that after the user registers and fills out the login form, he still stays on the same page. So one part of the page will be if the session is logged in and the other part will be otherwise (the user is not logged in so the login form is shown). Can someone tell me how to get started? </p>
This is the simplest session code written in PHP. We used 3 files.
login.php
home.php
logout.php
To start a session, you need to say this at the top of the page or before calling the session code
Put user ID into session to track who is logged in
Check if anyone is logged in
Find the ID of the logged in user
On your page