嗯。。现在不起作用了?
现在我希望能够扩展我的会话echo,这样我就可以添加用户名/全名等。如果你能向我展示我需要做什么来添加第二个,我就能从中找出如何扩展用户价值观。
尝试回显用户名,但也能够将其扩展到用户名、名字、姓氏、emp id等的不同页面上。
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'); ?>
更新。您需要在Access::login方法中设置一个会话变量来存储该信息。
Access::login(md5($u->username), $_REQUEST['return_url'], $_POST['username']);
将usernamepost对象传递给Access::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);