[英]Login form is not working after adding SSL certificate
我有一个登录表格:
<form method="post" action="verify.php" name="loginform">
<table border="0" bgcolor="orange" align="center">
<tr><td colspan="3"><h1><b>Please Enter Username and Password</b></h1></td></tr>
<tr>
<td><label>User Name</label>
</td>
<td>:
</td>
<td><input type="text" name="user"/>
</td>
</tr>
<tr><br/>
<td><label>Password</label>
</td>
<td>:
</td>
<td><input type="password" name="pwd"/>
</td>
</tr>
<tr><td colspan="3" align="center"><input type="submit" class="submit-green" value="Login"/></td>
</tr>
</table></form>
而且我有verify.php作为
<?php
session_start();
include "dbconfig.php";
$user=$_POST['user'];
$pwd=sha1($_POST['pwd']);
$sql='select * from admin where username="'.$user.'" AND password="'.$pwd.'"';
$res=mysql_query($sql) or die('Login query error:'. mysql_error());
if(mysql_num_rows($res)==1)
{
header("Location:index");
}
else
{
header("Location:login.php");
}
$row = mysql_fetch_array($res);
$_SESSION['admin']=$row['id'];
?>
这里有什么错误吗? 我找不到任何错误。 在我在网站上使用SSL证书之前,它一直运行良好。 现在不起作用。 我做了一个print_r请求,以了解通过post方法获取的值。 但是只有密码在获取,而且它是错误的SHA1值。 为什么会这样呢?
从HTTP切换到HTTPS时,您将丢失会话,因为HTTPS会话cookie上设置了Secure
标志,因此只能通过HTTPS访问它们。 这意味着切换到HTTPS时无法传输旧的HTTP会话cookie。 您可以尝试将HTTP会话传递到HTTPS。
这是另一个答案的例子:
HTTP代码:
$currentSessionID = session_id();
header('https://yoursite.com/login.php?session='.$currentSessionID);
HTTPS代码:
// Retrieve the session ID as passed via the GET method.
$currentSessionID = $_GET['session'];
// Set a cookie for the session ID.
session_id($currentSessionID);
显然,您将需要使其更加安全。 这只是一个传达总体思想的简单例子。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.