PHP-Login.net Advanced Script - how to allow logged in users access to other pages/"views"? -
i using php-login.net advanced script , see how when user logs in, goes logged_in view.
however, want user able go php page, want visible if logged in.
not sure if "view" of index.php or own page?
how make work? thanks!
<?php /** * simple php login script / advanced version * more versions (one-file, minimal, framework-like) visit http://www.php-login.net * * @author panique * @link http://www.php-login[dot]net */ // check minimum php version if (version_compare(php_version, '5.3.7', '<')) { exit('sorry, script not run on php version smaller 5.3.7 !'); } else if (version_compare(php_version, '5.5.0', '<')) { // if using php 5.3 or php 5.4 have include password_api_compatibility_library.php // (this library adds php 5.5 password hashing functions older versions of php) require_once('libraries/password_compatibility_library.php'); } // include config require_once('config/config.php'); // include to-be-used language, english default. feel free translate project , include else require_once('translations/en.php'); // include phpmailer library require_once('libraries/phpmailer.php'); // load login class require_once('classes/login.php'); // create login object. when object created, login/logout stuff automatically // single line handles entire login process. $login = new login(); // ... ask if logged in here: if ($login->isuserloggedin() == true) { // user logged in. can whatever want here. // demonstration purposes, show "you logged in" view. include("views/logged_in.php"); } else { // user not logged in. can whatever want here. // demonstration purposes, show "you not logged in" view. include("views/not_logged_in.php"); } ?>
i think if reuse code on second logged in page, work - if logged in = true, display page, if not true, display view of log in page.
so example, lets second "logged in only" page index2.php, have
<?php if ($login->isuserloggedin() == true) { // user logged in, display page include("views/index2.php"); } else { // user not logged in view. include("views/not_logged_in.php"); } ?>
okay looks using "index2.php" page, creates new session because have log in , out 2x ....
if click logout, shows login screen, if go "index2.php" directly, shows still logged in
this not correct solution ....
Comments
Post a Comment