I am trying to use custom error pages with a htaccess file.
I am using ErrorDocument 404 /404.php.
This page will check whether the user is logged in. It only displays when he/she is, otherwise it asks the user to log in.
But session variables are not available after an ErrorDocument redirection, so the page always thinks the user is not authenticated.
Here is the code:
session_start();
I log in, I am taken to the home page for the members (it sees the session variables, and normally shows)
(Redirection is done with header('Location: ...');)
I type an URL to a not-existing page, the 404.php shows but it does not see the session variables, and shows the error page for the not-authenticated visitors
I edit the URL again (manually) and put back an address to a valid page. The pages says I’m still logged in (session variables are here again).