2017-01-21 55 views
0

我曾在smarty的登錄頁面中「讓我登錄」。我想在登錄後在我的登錄頁面上查看電子郵件和密碼,並且我有一些問題,因爲Cookie值始終存儲在我的瀏覽器中,但未在我的登錄頁面中查看。如何查看我的登錄頁面中的cookie值?

我的PHP代碼是:

if (isset($_REQUEST['login'])) { 

    // $email=$_REQUEST['email']; 
    // $pass=$_REQUEST['pass']; 

    if (isset($_REQUEST['keeplogin'])) { 
     setcookie("Email", $_REQUEST['email'], time() + 3600); 
     setcookie("Pass", $_REQUEST['pass'], time() + 3600); 
     $email = $_COOKIE['Email']; 
     $pass = $_COOKIE['Pass']; 
    } 

    $smarty->assign('email', $email); 
    $smarty->assign('pass', $pass); 
} 

和我的登錄頁面

<form role="form" action="index.php" method="post" enctype="multipart/form-data"> 
    <div class="form-group"> 
     <label for="pwd">Email ID:</label> 
     <input class="form-control" type="email" placeholder="[email protected]" name="email" value="{$smarty.cookies.$email}" required="required" /> 
    </div> 
    <div class="form-group"> 
     <label for="pwd">Password:</label> 
     <input class="form-control" type="password" name="pass" value="{$pass}" required="required" /> 
     <h5 align="right"><a href="index.php?act=add_forgot_password">Forgot Password<span class="badge"></span></a></h5> 

    </div> 

    <div class="login button"> 
     <input type="submit" class="btn btn-primary" name="login" value="Login" style="width:100%; height:40px;" /> 
    </div> 

    <p class="keeplogin"> 
     <input type="checkbox" name="keeplogin" id="loginkeeping" value="keep_login" /> 
     <label for="loginkeeping">Keep me logged in</label> 
    </p> 
    <input type="hidden" name="act" value="{$act}" /> 
    <input type="hidden" name="u_id" value="{$u_id}" /> 
</form> 

如何查看電子郵件和密碼在登錄頁面智者?

回答

1

可以用PHP獲得cookie值這樣

echo "<b>Email:</b>".$_COOKIE['Email']; 
echo "<b>Pass:</b>".$_COOKIE['Pass']; 
相關問題