JPB Posted March 6, 2021 Report Share Posted March 6, 2021 (edited) Hi, I need your help please. I want to integrate a new page that should be accessible only for logged in users. I have built the page with the historytemplate.php, it works fine. Also the integration in the menu bar worked well. What code do I need to integrate at the top of the page that checks if the visitor is logged in? If he is NOT logged in, he should be redirected to the login page. Thanks and have a nice weekend Jürgen ----------------------- I think I have found my mistake. I had inserted the code: if (!$currentuser && !$_SESSION['currentuser']) {header('location: ../login.php'); exit;} before include( "../tng_begin.php"); But it must be inserted BELOW this line, then everything works as desired. Learning by doing ...😁 Jürgen Edited March 6, 2021 by JPB done Quote Link to comment Share on other sites More sharing options...
RickM Posted March 6, 2021 Report Share Posted March 6, 2021 Well done you!! Indeed, 'Learning by Doing' Quote Link to comment Share on other sites More sharing options...
Michel KIRSCH Posted March 7, 2021 Report Share Posted March 7, 2021 On 3/6/2021 at 8:28 AM, JPB said: What code do I need to integrate Hi Jürgen, in the historytemplate.php file, these lines : //1a: If you want to skip the login check when displaying this page, remove the comment marks from this line: //$nologin = 1; indicates that you have nothing to do/integrate to check if a user is connected... Why must you insert your own code? Michel Quote Link to comment Share on other sites More sharing options...
JPB Posted March 7, 2021 Author Report Share Posted March 7, 2021 vor 1 Minute schrieb Michel KIRSCH: Why must you insert your own code? ... because this code has no function (at least for me?). Quote Link to comment Share on other sites More sharing options...
tngrlkrz Posted March 7, 2021 Report Share Posted March 7, 2021 1 hour ago, Michel KIRSCH said: Why must you insert your own code? Could it be because Jurgen's site Genealogische Datenbank (Public site) normally is 'public' and doesn't require a login? Then the $nologin might have no effect. Just a thought. Quote Link to comment Share on other sites More sharing options...
Ken Roy Posted March 7, 2021 Report Share Posted March 7, 2021 2 hours ago, Michel KIRSCH said: in the historytemplate.php file, these lines : //1a: If you want to skip the login check when displaying this page, remove the comment marks from this line: //$nologin = 1; indicates that you have nothing to do/integrate to check if a user is connected... The $nologin check was added to the historytemplate.php in TNG v12 to bypass the login check for users who require login on their sites and wanted to allow certain pages to be available to anonymous users. What Jürgen wanted was the opposite - restrict a page to logged in users on a site that does not require login Quote Link to comment Share on other sites More sharing options...
Michel KIRSCH Posted March 7, 2021 Report Share Posted March 7, 2021 Thx Ron and Ken. It's clear now ! Michel Quote Link to comment Share on other sites More sharing options...
Ken Roy Posted March 7, 2021 Report Share Posted March 7, 2021 The wiki article on $nologin_option should be updated to provide a better explanation. The previous version of the historytemplate.php allowed users to comment out the call to checklogin.php if your site required login and you wanted to make certain pages available without requiring the login Quote Link to comment Share on other sites More sharing options...
Michel KIRSCH Posted March 7, 2021 Report Share Posted March 7, 2021 1 minute ago, Ken Roy said: if your site required login and you wanted to make certain pages available without requiring the login Ah ! It's well what i've thinked... Thx Ken Quote Link to comment Share on other sites More sharing options...
JPB Posted March 8, 2021 Author Report Share Posted March 8, 2021 vor 13 Stunden schrieb Ken Roy: if your site required login and you wanted to make certain pages available without requiring the login thank you all. I actually assumed a different function. This command releases something, but I thought it would prevent something. Learning by listening ... 🤣 Jürgen Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.