我从表单中注销时没有设置Cookie

时间:2014-10-03 10:17:42

标签: cookies

我的登录表单包含电子邮件字段和密码字段。

我在提交登录表单时遇到问题,并选中“保持登录复选框”。 当我从表单中注销时,我无法获取数据“emailId”,因此我的cookie无效。 看看我的cookie代码如下:

if (isset($_POST['rememberCheck'])) {                     
    $year = time() + 3600;      
    setcookie('remember_me', $unm, $year);      
} 

我的登录表单:

<form id="frm_login" name="frm_login" action="<?php echo CONTROLLERS."/signindetail/loginchk"; ?>" method="POST" >
   <?php if($_GET['errmsg']!="" || $_GET['errdbmsg']!="") { ?>
  <div class="errMsg"><?php if(isset($_GET['errdbmsg'])){echo $dbMessages[$_GET['errdbmsg']];}if(isset($_GET['errmsg'])){echo $error[$_GET['errmsg']];} ?></div>
  <?php } ?>
  <div class="form_inner">
     <label for="email">Username / Email Address</label>
     <input required type="text" placeholder="Username / Email Address" id="email" name="email" value="<?php echo $_COOKIE['remember_me']; ?>" >
     <div id="erremail" class="errMsg"></div>
  </div>
  <div class="form_inner">
     <label for="password">Password</label>
     <input required type="password" placeholder="password" id="password" name="password" value="<?php echo $_COOKIE['memberPass']; ?>" >
     <div id="errpassword" class="errMsg" ></div>
  </div>
  <div class="form_inner">
      <input type="checkbox" id="checkbox" name="rememberCheck" <?php if(isset($_COOKIE['remember_me'])){echo "checked='checked'";}?>>
      <label for="checkbox">Stay Logged In</label>
  </div>
  <div class="form_inner">
       <img src="<?php echo VIEWS; ?>templates/captcha/captcha.php" style="margin-bottom:10px;" />
        <input type="text" id="email" required class="cap_ans" name="cap_ans" placeholder="Enter captcha here" />                                
        <div id="errcap" class="errMsg"></div>
  </div>
  <div class="login_btn">
       <input type="submit" value="Submit" class="btn">
  </div>
  <p>Forgot your password? <a class="click_here" data-popup-target="#forgot-popup">Click Here</a></p>
</form>

提供您的建议。 问候, Bhavesh Vala

0 个答案:

没有答案