Copy link to clipboard
Copied
I've created a simple login using the inbuilt DW suite, but I don't seem to be able to display the session variable after they login.
On the success page it should filter the RS based on the Username and also display the Username etc on the page but nothing is shown. I tested the success page in DW and entered a value for the session var and it works fine, all I can think of is that the session is empty, not coming through, but I'm clueless. ![]()
Any ideas?
<<<<<LOGIN PAGE>>>>>
<?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['UserName'])) {
$loginUsername=$_POST['UserName'];
$password=$_POST['Password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "login_successful.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_connpbxlogin, $connpbxlogin);
$LoginRS__query=sprintf("SELECT UserName, UserPassword FROM Users WHERE UserName=%s AND UserPassword=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $connpbxlogin) 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']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<<<<<SUCCESS PAGE>>>>>
$colname_LoggedRS = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_LoggedRS = $_SESSION['MM_Username'];
}
mysql_select_db($database_connpbxlogin, $connpbxlogin);
$query_LoggedRS = sprintf("SELECT * FROM Users WHERE UserName = %s", GetSQLValueString($colname_LoggedRS, "text"));
$LoggedRS = mysql_query($query_LoggedRS, $connpbxlogin) or die(mysql_error());
$row_LoggedRS = mysql_fetch_assoc($LoggedRS);
$totalRows_LoggedRS = mysql_num_rows($LoggedRS);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
</p>
<p>username: <?php echo $row_LoggedRS['UserFirstName']; ?></p>
<p>email: <?php echo $row_LoggedRS['UserEmail']; ?></p>
<p>Session Data:
<?php echo $_SESSION['MM_Username']; ?></p>
</body>
</html>
<?php
mysql_free_result($LoggedRS);
?>
Copy link to clipboard
Copied
Does your success page begin with session_start()?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now