Echo user details after successful login

Eh .. Now its not working?

Now, I would like to be able to extend the echo session so that I can add username / file_name / etc. if you can show me what I need to do to add a second, I can figure out how to expand user values.

Trying to repeat the username, but can also expand it to different pages for username, first name, last name, emp name, etc.

access.php

    <?php
    class Access {      
final public function login( $id, $url = false, $user ) {
        $_SESSION[LOGINSESSION] = $id;

        //you would do this for all columns
        $_SESSION['user'] = $user;

        if ( $url )
            new Redirect(urldecode($url));
        else
            new Redirect(URL);
    }

        final public function require_login() {
            if ( ! self::is_logged(true) )
                self::not_logged();
        }
    }

index.php

    <?php require_once('../admin/pinAPP.php'); $pinAPP = new pinAPP( 'newhire', false, false, true ); ?>
<?php if ( $pinAPP->can_access() ) { ?><!-- New hire -->
    <center>
        <div class="panel">
                    <div>
                        <br>
                            <b><?= $_SESSION['user']['username']; 
//or
$_SESSION['user']['FirstName']; ?>,</b>
                        <br>
                        <br>
                            <p>Below you will find all the necessary information on needed for onboarding process.</p>                  
                        <br> 
                        <br>
                    </div>
<?php } else {} ?>

<!-- -->

<?php include('footer.php'); ?>
+4
source share
1 answer

UPDATED. You need to set the session variable in the Access :: login method to store this information.

Access::login(md5($u->username), $_REQUEST['return_url'], $_POST['username']);

post name :: login, :

final public function login( $id, $url = false, $username ) {
        $_SESSION[LOGINSESSION] = $id;
        $_SESSION['username'] = $username;

        if ( $url )
            new Redirect(urldecode($url));
        else
            new Redirect(URL);
    }

pinAPP:

 <?php require_once('../admin/pinAPP.php'); $pinAPP = new pinAPP( 'newhire', false, false, true ); ?>
<?php if ( $pinAPP->can_access() ) { ?><!-- New hire -->
    <center>
        <div class="panel">
                    <div>
                        <br>
                            <b><?= $_SESSION['username']; ?>,</b>
                        <br>
                        <br>
                            <p>Below you will find all the necessary information on needed for onboarding process.</p>                  
                        <br> 
                        <br>
                    </div>
<?php } else {} ?>

:

final public function login( $id, $url = false, $user ) {
        $_SESSION[LOGINSESSION] = $id;

        //you would do this for all columns
        $_SESSION['user'] = $user;

        if ( $url )
            new Redirect(urldecode($url));
        else
            new Redirect(URL);
    }

, :

$_SESSION['user']['username']; 
//or
$_SESSION['user']['FirstName'];

:

$userRow = $sql->sqls("UPDATE `". DBPREFIX ."users` SET `last_login_ip` = '". $ip ."', `last_login_timestamp` = '". time() ."' WHERE `username`='$user'");
Access::login(md5($u->username), $_REQUEST['return_url'],$userRow);
+1

Source: https://habr.com/ru/post/1616007/


All Articles