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

时间:2015-03-22 19:47:15

标签: php session login

我在用户登录系统时定义了一些会话变量。当他们点击“提交”时,它会转到“check-login.php”,它会检查一些指定的标准(用户是否为管理员以及用户是否存在)。

我正在连接第三方系统,我正在检查登录凭据。基本上,用户将其电子邮件作为用户名输入,并调用第三方API以查看电子邮件是否存在。如果是,它会检查密码并将$ _SESSION ['myusername']设置为电子邮件,将$ _SESSION ['mypassword']设置为密码。

一切正常。我遇到的问题是当它重定向到“index.php”时,我有一个重定向设置,以防万一有人试图在没有登录的情况下访问“index.php”。好吧,由于某种原因没有会话变量被转移到“的index.php”。

签的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有“session_start();”和一些杂项功能

index.php(只是标题)

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

login-success是重定向发生的地方

// 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']转回login.php并显示正常,因此$ _SESSION ['myusername']发生了一些事情,它没有从check-login.php继承而来

在“login-success.php”中,我在SESSION上使用了print_r,它没有返回任何内容。将print_r移动到“index.php”的第二行也不会返回任何内容。

0 个答案:

没有答案
相关问题