douchun1948 2015-03-22 19:47
浏览 35

用户名和密码会话变量未携带,但其他会话变量携带

I have a few session variables that I define when the user logs into the system. When they click "submit" it goes to "check-login.php" where it checks for a few specified criteria (whether user is admin or not and if the user exists).

I am connecting to a 3rd party system where I am checking for login credentials. Basically, the user puts in their email as the username and it calls the 3rd party api to see if the email exists. If it does, it checks password and sets $_SESSION['myusername'] to the email and $_SESSION['mypassword'] to the password.

That all works just fine. Where I run into issues is when it redirects to "index.php", I have a redirect setup just in case someone tries to access "index.php" without logging in. Well, for some reason no session variables are carried over to "index.php".

check-login.php

<?php include('../includes/session.php'); 
// Register $myusername, $mypassword and redirect to appropriate location
$_SESSION['myusername'] = $myusername;
$_SESSION['mypassword'] = $mypassword; 
header('Location: index.php');

session.php has "session_start();" and some miscellaneous functions

index.php (just the header)

<?php include("../includes/session.php"); ?>
<?php include("../includes/functions.php"); ?>
<?php include("../public/login-success.php"); ?>

login-success is where the redirect happens

// Check if session is not registered, redirect back to main page
if (!isset($_SESSION['myusername'])) {
    $_SESSION['message'] = 'You need to be logged in to do that';
    redirect_to('../public/login.php'); 
}

$_SESSION['message'] carries over back to login.php and displays just fine so something is happening with $_SESSION['myusername'] to where it's not carrying over from check-login.php

In "login-success.php" I used print_r on SESSION and it didn't return anything. Moving the print_r to the 2nd line of "index.php" doesn't return anything either.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度