简体   繁体   English

使用标头重定向后,会话变量将丢失

[英]Session Variables are lost after redirect with header

i want to store some information in session variablle after login process. 我想在登录过程后将一些信息存储在会话变量中。 i can print the session variables in login post method succesfully. 我可以在登录后方法中成功打印会话变量。 ie, i can fill the session variables. 即,我可以填写会议变量。 if the user logined succesfully, i redirected to index but my session variables becomes empty. 如果用户成功登录,我将重定向到索引,但是我的会话变量为空。

My Login Post page : 我的登录页面:

    if($totalRows_Recordset1>0)
    {
        session_start();
        $_Session['Mail']=$un;
        $_Session['Password']=$p;

        header("location: Index.php"); 
        die();

    }

My Index page : 我的索引页面:

<?php session_start(); echo $_Session['Mail']; ?>

$_SESSION needs to be capitalized, it's case sensitive. $_SESSION需要大写,区分大小写。 $_Session prints because you are declaring a local variable called $_Session. $ _Session会打印,因为您声明了一个名为$ _Session的局部变量。 Let me know if it works :) 让我知道它是否有效:)

Yea....capitalize $_SESSION try this $_SESSION['mail']=$un; 是的....大写$ _SESSION试试这个$ _SESSION ['mail'] = $ un;

Then in index page... echo $_SESSION['mail']; 然后在索引页中... echo $ _SESSION ['mail'];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM