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:
The session parameter and the redirect location depends on the architecture that you're using on your web project.
The login script you are using is already checking if the user id logged in in the
index.php
:You can change this
include("views/not_logged_in.php");
to whatever page you want.When you determine that they are not logged in you can issue a redirection header:
This is described in detail in the PHP Manual: Header.
or in javascript