check if session is started php 1

check if session is started php

if (session_status() == PHP_SESSION_NONE) {
    session_start();
}

Here is what the above code is Doing:
1. We’re checking if the session has already been started. If it hasn’t, we start it.
2. We’re checking if the user is logged in. If they are, we redirect them to the home page.
3. We’re checking if the user has submitted the login form. If they have, we check if the username and password are correct. If they are, we log the user in.
4. We’re checking if the user has submitted the register form. If they have, we check if the username and password are valid. If they are, we register the user.

Similar Posts