idk what the syntax is, what I want to happen is that when I type localhost/farm-e-mart the first file that will show is the login system, how can I do that?
CodePudding user response:
check for cookies/session if the user is not logged in then redirect to login page.
if logging in is not compulsory but you want to make sure that user sees login page then create a session that gets initiated in login page. and check in other page if the session is there or not and then redirect
CodePudding user response:
Firstly if your web app permit user authentication, do this.
On the page, you don't want unauthenticated user to have access to, add this code at the top of the code script e.g profile.php
session_start();
if(!isset($_SESSION){
header("location:login.php");
}
Then, on the login page add this code snippet.
session_start();
if(isset($_SESSION){
header("location:profile.php");
}