I want to store passwords for users on my site. At login, no problem and everything is running normally. However, after the Closed the browser, the cookie is deleted, so that the password and username disappeared.
A php script like this
<?php
}
else
{
$ousername = '';
if(isset($_POST['username'], $_POST['password']))
{
if(get_magic_quotes_gpc())
{
$ousername = stripslashes($_POST['username']);
$username = mysql_real_escape_string(stripslashes($_POST['username']));
$password = stripslashes($_POST['password']);
}
else
{
$username = mysql_real_escape_string($_POST['username']);
$password = $_POST['password'];
}
$req = mysql_query('select password,id from users where username="'.$username.'"');
$dn = mysql_fetch_array($req);
if($dn['password']==sha1($password) and mysql_num_rows($req)>0)
{
$form = false;
$_SESSION['username'] = $_POST['username'];
$_SESSION['userid'] = $dn['id'];
if(isset($_POST['memorize']) and $_POST['memorize']=='yes')
{
$one_year = time()+(60*60*24*365);
setcookie('username', $_POST['username'], $one_year);
setcookie('password', sha1($password), $one_year);
}
?>
What is the best solution to this problem? Thanks for the answer