How can I first show the syntax for logging into the system when I type a folder name in localhost
P粉351138462
P粉351138462 2024-04-02 14:32:52
0
2
391

Don’t know what the syntax is? What I want to happen is that when I type localhost/farm-e-mart the first file should show the login system. How can I do this?

P粉351138462
P粉351138462

reply all(2)
P粉529245050

If the user is not logged in, check the cookie/session and redirect to the login page.

If login is not mandatory but you want to ensure the user sees the login page, create a session that is started in the login page. And check if the session exists on other pages and then redirect

P粉463840170

First, if your web application allows user authentication, do so.

On a page you don't want unauthenticated users to access, add this code to the top of your code script, for example profile.php

session_start();
if(!isset($_SESSION){
   header("location:login.php");
}

Then, add this code snippet on the login page.

session_start();
if(isset($_SESSION){
header("location:profile.php");
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!