CODE
<?php require_once('../Connections/ilovephysics.php'); ?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['email'])) {
$loginUsername=$_POST['email'];
$pass=$_POST['password'];
//encode password
$password = md5($pass);
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "../buy/user.php";
$MM_redirectLoginFailed = "loginfail.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_ilovephysics, $ilovephysics);
$LoginRS__query=sprintf("SELECT email, password FROM tbl_users WHERE email='%s' AND password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $ilovephysics) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
I am interested in making a session cookie for my site but don't know how to implement it into the above Dreamweaver code. The session cookie needs to be able to use the loginUsername value to find the users details stored in the database and display it to them on the members panel.
From here they edit the values e.g. their passwords. Does anyone have pointers on where I can start? Any help would be much appreciated!
I'm guessing that would mean that the cookie would need to be loaded on the page that login redirects you to. It would also need to be deleted on logout.
Thanking you in advance!