I have been trying to make this following functionality work on my website, however I'm kinda struggling with it. Perhaps one of you can help me out?
I am developing a website which must be inaccessible (except the login of course) unless you are logged in. I was trying to make an automatic redirect to the login page if the user isn't logged in. I'm using HTML, CSS, and PHP at the moment.
If my remaining source is needed please tell me, I'll temporarily host the site online.
If you're not using any frameworks, try simply:
if(!isset($_SESSION['login'])){ //if login in session is not set
header("Location: http://www.example.com/login.php");
}
The session parameter and the redirect location depends on the architecture that you're using on your web project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With