Php 会话数组中的下一个变量正在写入的会话变量

Php 会话数组中的下一个变量正在写入的会话变量,php,session,Php,Session,好的,我有一个导航栏链接,点击它就会转到language.php 我的导航栏代码位于单独的视图文件夹views/header/header2.php <?php $_SESSION['from'] = $_SERVER['REQUEST_URI']; ?> <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation" style="position:top"> <div

好的,我有一个导航栏链接,点击它就会转到language.php

我的导航栏代码位于单独的视图文件夹
views/header/header2.php

<?php 
    $_SESSION['from'] = $_SERVER['REQUEST_URI'];
?>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation" style="position:top">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" class="sr-only"><img src="images/dp.png"></button>
            <a class="navbar-brand" href="index.php">
            <img src="views/images/cp.png" title="###.###" alt="logo" width="90px" height="48px" style="padding-top:2px"></a>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav navbar-right">
            <li><a href="profile.php?id=<?php echo $_SESSION['user_id'] ?>"><span class="glyphicon glyphicon-user" ></span> <?php echo HEADER_PAGE; ?></a></li>
            <li><a href="search.php"><span class="glyphicon glyphicon-search"></span> <?php echo HEADER_SEARCH; ?></a></li>
            <li><a href="post.php"><span class="glyphicon glyphicon-plus"></span> <?php echo HEADER_POST; ?></a></li>   
            <li><a href="community.php"><span class="glyphicon glyphicon-edit"></span> <?php echo HEADER_COMMUNITY; ?></a></li>
            <li><a href="edit.php"><span class="glyphicon glyphicon-cog"></span> <?php echo HEADER_EDIT; ?></a></li>
            <li><a href="language.php"><span class="glyphicon glyphicon-flag"></span> <?php echo HEADER_LANGUAGE; ?></a></li>
            <li style="background-color:white"><a style="color:black" href="index.php?logout"><?php echo WORDING_LOGOUT; ?></a></li>
            </ul>
        </div>
        <!-- Collapse -->
    </div>
</nav>
另外,我已通过.htaccess关闭了已注册的全局访问


非常感谢您的帮助。

我将$\u会话['from']重命名为$\u会话['link'],修复了此问题,它再次正常工作。我假设$\u SESSION['from']试图被其他东西设置。我已经浏览了所有涉及这些操作的代码,但什么都没有。有人解释为什么它将$\u SESSION['从']的值更改为$\u SESSION['用户id']的值吗


与$from=$\u SESSION['from']一样,它被分配了$\u SESSION['user\u id']]的值。

尝试在header2.php中打印$\u SERVER['REQUEST\u URI'],以便在每个页面上都能看到它。在所有情况下,在所有页面上都正确吗?是的,在所有页面上,它在所有页面上都显示了正确的变量。只有当我单击链接时,它才会将变量更改为数字3。这是$_SESSION['user_id']的值;你说如果你向header2.php添加以下内容:
echo“URI:>”$\u SERVER['REQUEST\u URI']”。不,这将显示URI:>index.php?不清楚所有内容是如何组合在一起的。language.php何时启动的?它是否包含在index.php中?header2.php呢?我想是的,但不清楚,也看不到任何地方
<?php
    session_start();
    if(isset($_SESSION['lang'])){
        $from = $_SESSION['from'];
        $langSession = $_SESSION['lang'];
        if($langSession == "th"){
            $_SESSION['lang'] = "en";
            //header('Location:http://www.###.###'.$from);
            echo $from;
        } elseif ($langSession == "en"){
            $_SESSION['lang'] = "th";
            //header('Location:http://www.###.###'.$from);
            echo $from;
        }
        if(!(isset($langSession))){
            $_SESSION['lang'] = "en";
            //header('Location:http://www.###.###'.$from);
            echo $from;
        }
    } 
?>
<?php
ob_start();
// check for minimum PHP version
if (version_compare(PHP_VERSION, '5.3.7', '<')) {
    exit('Sorry, this script does not run on a PHP version smaller than 5.3.7 !');
} else if (version_compare(PHP_VERSION, '5.5.0', '<')) {
    // if you are using PHP 5.3 or PHP 5.4 you have to include the password_api_compatibility_library.php
    // (this library adds the PHP 5.5 password hashing functions to older versions of PHP)
    require_once('libraries/password_compatibility_library.php');
}
// include the config
require_once('config/db/config.php');

// include translation
session_start();
if(isset($_SESSION['lang'])){
    $lang = $_SESSION['lang'];
} elseif(!(isset($_SESSION['lang']))) {
    $_SESSION['lang'] = "en";
    $lang = $_SESSION['lang'];
}
$_SESSION['from'] = $_SERVER['REQUEST_URI'];

require_once("translations/$lang.php");

// include the PHPMailer library
require_once('libraries/PHPMailer.php');

// load the login class
require_once('classes/Login.php');

// create a login object. when this object is created, it will do all login/logout stuff automatically
// so this single line handles the entire login process.
$login = new Login();

// ... ask if we are logged in here:
if ($login->isUserLoggedIn() == true){
    // the user is logged in. you can do whatever you want here.
    // for demonstration purposes, we simply show the "you are logged in" view.
    include("views/logged_in.php");
} else {
    // the user is not logged in. you can do whatever you want here.
    // for demonstration purposes, we simply show the "you are not logged in" view.
    include("views/landing.php");
}