Hey friends I've a doubt regarding my password authentication code given below
If we use session _start
function one need not use the cookies
as
$_SESSION['user'] = $username;
$_SESSION['password'] = $password;
functions do the same job that cookies would have done so my cookies code is just a clutter??
Here's my code
<?PHP
session_start();
?>
<?php
include "connect.php";
include 'var.php';
print "<link rel='stylesheet' href='http://127.0.0.1/styles/styles.css' type='text/css'>";
if (isset($_POST['submit'])) // name of submit button
{
$username = $_POST['username'];
$password = $_POST['password'];
$password = md5($hash . md5($password));
$query = "SELECT* from moderators where username='$username' and password='$password'";
$usercheck1 = mysql_query($query) or die(mysql_error());
$usercheck2 = mysql_num_rows($usercheck1);
if ($usercheck2)
{
$_SESSION['user'] = $username;
$_SESSION['password'] = $password;
if ($_POST['remember'])
{
$memberid = $result2[username];
$passkey = $result2[password];
[COLOR=Green]$cookie1 = "[0]";
$cookie2 = "[1]";
$cookie3 = "$cookiename$cookie1";
$cookie4 = "$cookiename$cookie2";
setcookie("$cookie3", "$memberid", time() + 7776000);
setcookie("$cookie4", "$passkey", time() + 7776000);[/COLOR]
}
print "<center>";
print "<table class='tborder' cellpadding='6' cellspacing='1' border='0'>";
print "<tr><td class='panelsurround' align='center'><center>Logged In</center></td></tr></table></center>";
print "<META HTTP-EQUIV = 'Refresh' Content = '2; URL =http://127.0.0.1/register.php'></center>";
}
else
{
print "<center>";
print "<table class='tborder' cellpadding='6' cellspacing='1' border='0'>";
print "<tr><td class='panelsurround' align='center'><center>Invalid username or password</center></td></tr></table></center>";
//print "<META HTTP-EQUIV = 'Refresh' Content = '2; URL =http://127.0.0.1/login.php'></center>";
}
}
?>