如何在我的登录页面中查看cookie值?

时间:2017-01-21 05:53:30

标签: php mysql smarty

我已经在smarty的登录页面中“保持登录状态”。我想在登录后查看登录页面上的电子邮件和密码,我有一些问题,因为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="example@mail.com" 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>

如何在登录页面中使用smarty查看电子邮件和密码?

1 个答案:

答案 0 :(得分:1)

你可以在php中获得cookie值

dropDownSelected(selected) {
  this.state.selectedValue = ...
}
render(){
 let dropDownValues = this.state.dropDownValues;
 let dropDowns = [];
 for (let i=0; i<this.state.counter;i++){
    dropDowns.push(<DropDown key={i} values={dropDownValues} onDropDownSelected={this.dropDownSelected.bind(this)} />
 }

 return(
     <div>
        {dropDowns}
        <button onClick={()=>this.addDropDown()}>+</button>
        <button onClick={()=>this.removeDropDown()}>-</button>
        <form method="post" onsubmit={this.postToWebservice(allTheStuffFromTheDropDownsContext)}>
       <input type="submit" value="Submit Request To WebService"
        </form>
     </div>
 );
}