close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

session variables not being stored from login page to index page

Thread began 9/28/2019 3:15 pm by sandy170299 | Last modified 10/02/2019 7:23 pm by Ray Borduin | 971 views | 11 replies |

sandy170299

session variables not being stored from login page to index page

I applied the MySQLi Log In User behavior to the form on my login page. Fields are email and password. I'm storing user_id, user_email,and acct_number.

It's redirecting to my index page, but I can't get the session variables to show up.

My recordset is (index page):
<?php
$getUser = new WA_MySQLi_RS("getUser",$numeroseti,1);
$getUser->setQuery("SELECT users.* FROM users WHERE users.user_id = ?");
$getUser->bindParam("i", "".$_SESSION['user_id'] ."", "-1"); //WAQB_Param1
$getUser->execute();
?>

I'm including relevant screen prints.

Thank you!

Sign in to reply to this post

Ray BorduinWebAssist

It could be a problem with the session_save_path in your php.ini file and sessions might just be not working. Is there anything else that might be taking it to the index page? Are you sure the session variables aren't being saved.

I'd probably debug by setting a session variable in php on one page and see if I can access it on another page. If the site doesn't store sessions properly then the code on the pages isn't the problem.

If sessions work, then I'd consider if it is somehow going to the index page without running the login code. Maybe the form action is set wrong?

Sign in to reply to this post
Did this help? Tips are appreciated...

sandy170299

My login name (MySQLi Login User) is user_id. I am also referencing this field in my log out page, using the MySQLi Log Out User server behavior (see screen print). It's not working. It's actually not logging me out. I tried a different browser this morning. Session variables DO work, as I'm using them again and again in the application for different processes.

This is my login form:
******************************
<form action="index.php" method="post" name="loginUser" onsubmit="MM_validateForm('email','','R','password','','R');return document.MM_returnValue">
<label for="email">Email</label>
<input name="email" type="text" id="email" value="leo@websailer.com" />
<label for="password">Password</label>
<input name="password" type="password" id="password" value="demo" />
<input name="submit" type="submit" value="Login" />
</form>

This is my login user script:
******************************
<?php
$Authenticate = new WA_MySQLi_Auth($numeroseti);
$Authenticate->Action = "authenticate";
$Authenticate->Trigger = (isset($_POST["submit"]) || isset($_POST["submit_x"]));
$Authenticate->Name = "user_id";
$Authenticate->Table = "users";
$Authenticate->addFilter("user_password_hash", "=", "s", "".((isset($_POST["password"]))?$_POST["password"]:"") ."");
$Authenticate->addFilter("user_email", "=", "s", "".((isset($_POST["email"]))?$_POST["email"]:"") ."");
$Authenticate->storeResult("user_id", "user_id");
$Authenticate->storeResult("acct_number", "acct_number");
$Authenticate->storeResult("user_email", "user_email");
$Authenticate->RememberMe = false;
$Authenticate->SaveLogin = false;
$Authenticate->AutoReturn = false;
$SuccessRedirect = "index.php";
$FailedRedirect = "";
if (function_exists("rel2abs")) $SuccessRedirect = $SuccessRedirect?rel2abs($SuccessRedirect,dirname(__FILE__)):"";
if (function_exists("rel2abs")) $FailedRedirect = $FailedRedirect?rel2abs($FailedRedirect,dirname(__FILE__)):"";
$Authenticate->SuccessRedirect = $SuccessRedirect;
$Authenticate->FailRedirect = $FailedRedirect;
$Authenticate->execute();
?>

This is on index.php:
*****************************
<?php session_start(); ?>
<?php require_once('Connections/numeroseti.php'); ?>
<?php require_once('webassist/mysqli/rsobj.php'); ?>
<?php require_once('webassist/mysqli/authentication.php'); ?>
<?php
$getUser = new WA_MySQLi_RS("getUser",$numeroseti,1);
$getUser->setQuery("SELECT * FROM users WHERE user_id = ?");
$getUser->bindParam("i", "".(isset($_SESSION['user_id'])?$_SESSION['user_id']:"") ."", "-1"); //colname
$getUser->execute();
?>

Sign in to reply to this post

Ray BorduinWebAssist

I see the problem.... your login name is set here: $Authenticate->Name = "user_id";

But then you save a row result with the same session variable name here: $Authenticate->storeResult("user_id", "user_id");

That is causing a conflict. One or the other has to be updated so that they are unique.

Sign in to reply to this post
Did this help? Tips are appreciated...

sandy170299

So, I'm basically setting the session variable with the same name twice? Is that what you're saying? Where do you recommend I remove it from? The store values screen in the module?

Thank you.

Sign in to reply to this post

Ray BorduinWebAssist

Yes... I'd update the login name in the UI and then you will have to redo any page access rules and logout to match the new name.

Sign in to reply to this post
Did this help? Tips are appreciated...

sandy170299

Thank you. I can give that a try this evening.

Sign in to reply to this post

sandy170299

Still not working. I created brand new login series of pages, and it doesn't redirect me, or give me any errors. It is supposed to redirect to index.php. This is in a completely different directory than what I was working on previously with this post.

Here is my login page:

<?php require_once('../Connections/numeroseti.php'); ?>
<?php require_once("../webassist/form_validations/wavt_scripts_php.php"); ?>
<?php require_once("../webassist/form_validations/wavt_validatedform_php.php"); ?>
<?php require_once('../webassist/mysqli/authentication.php'); ?>
<?php require_once( "../webassist/security_assist/helper_php.php" ); ?>
<?php
if ((isset($_POST["LogIn_submit"]) || isset($_POST["LogIn_submit_x"]))) {
$WAFV_Redirect = "".($_SERVER["REQUEST_URI"]) ."?invalid=true";
$_SESSION['WAVT_login_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateRQ((isset($_POST["Log_In_group_user_name"])?$_POST["Log_In_group_user_name"]:"") . "",true,1);
$WAFV_Errors .= WAValidateEL((isset($_POST["Log_In_group_user_name"])?$_POST["Log_In_group_user_name"]:"") . "",6,100,true,2);
$WAFV_Errors .= WAValidateRQ((isset($_POST["Log_In_group_2_user_password_hash"])?$_POST["Log_In_group_2_user_password_hash"]:"") . "",true,3);
$WAFV_Errors .= WAValidateEL((isset($_POST["Log_In_group_2_user_password_hash"])?$_POST["Log_In_group_2_user_password_hash"]:"") . "",6,500,true,4);

if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"login");
}
}
?>
<?php
$Authenticate = new WA_MySQLi_Auth($numeroseti);
$Authenticate->Action = "authenticate";
$Authenticate->Trigger = (isset($_POST["LogIn_submit"]) || isset($_POST["LogIn_submit_x"]));
$Authenticate->Name = "user_id";
$Authenticate->Table = "users";
$Authenticate->addFilter("user_name", "=", "s", "".((isset($_POST["Log_In_group_user_name"]))?$_POST["Log_In_group_user_name"]:"") ."");
$Authenticate->addFilter("user_password_hash", "=", "s", "".((isset($_POST["Log_In_group_2_user_password_hash"]))?$_POST["Log_In_group_2_user_password_hash"]:"") ."");
$Authenticate->storeResult("user_id", "SecurityAssist_user_id");
$Authenticate->RememberMe = (isset($_POST["Log_In_group_3_Remember_my_information"]));
$Authenticate->SaveLogin = (isset($_POST["Log_In_group_4_Log_me_in_automatically"]));
$Authenticate->AutoLogin = true;
$Authenticate->AutoReturn = true;
$SuccessRedirect = "index.php";
$FailedRedirect = "login.php?failedLogin=1";
if (function_exists("rel2abs")) $SuccessRedirect = $SuccessRedirect?rel2abs($SuccessRedirect,dirname(__FILE__)):"";
if (function_exists("rel2abs")) $FailedRedirect = $FailedRedirect?rel2abs($FailedRedirect,dirname(__FILE__)):"";
$Authenticate->SuccessRedirect = $SuccessRedirect;
$Authenticate->FailRedirect = $FailedRedirect;
$Authenticate->execute();
?>
<!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>
<script src="../webassist/progress_bar/jquery-blockui-formprocessing.js" type="text/javascript"></script>
<link href="../webassist/forms/fd_basic_default.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="../webassist/jq_validation/Bloom.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
</head>

<body>
<?php if(WA_Auth_RulePasses("Validated form")){ // Begin Show Region ?>
<p>Invalid username or password</p>
<?php } // End Show Region ?>
<?php if(WA_Auth_RulePasses("Log in success")){ // Begin Show Region ?>
<p>You have been logged in</p>
<?php } // End Show Region ?>
<?php if(WA_Auth_RulePasses("Failed log in")){ // Begin Show Region ?>
<p>Invalid username or password</p>
<?php } // End Show Region ?>
<?php if(WA_Auth_RulePasses("Emailed password")){ // Begin Show Region ?>
<p>Password information emailed, please check your inbox</p>
<?php } // End Show Region ?>
<?php if(WA_Auth_RulePasses("Successful update")){ // Begin Show Region ?>
<p>Registration completed successfully, please log in to access the site</p>
<?php } // End Show Region ?>
<div id="LogInContainer" class="WAATK">
<div id="LogIn_Basic_Default_ProgressWrapper">
<form class="Basic_Default" id="LogIn_Basic_Default" name="LogIn_Basic_Default" method="post" action="">
<fieldset class="Basic_Default" id="Log_In">
<legend class="groupHeader">Log In</legend>
<span class="fieldsetDescription"> Required * </span>
<div class="lineGroup">
<label for="Log_In_group_user_name" class="sublabel" > user_name:<span class="requiredIndicator">&nbsp;*</span></label>
<input id="Log_In_group_user_name" name="Log_In_group_user_name" type="password" value="" class="formPasswordfield_Medium" tabindex="1" title="Please enter a value." confirm="" required="true" />
<?php
if (ValidatedField('login','login')) {
if ((strpos((",".ValidatedField("login","login").","), "," . "1" . ",") !== false || "1" == "") || (strpos((",".ValidatedField("login","login").","), "," . "2" . ",") !== false || "2" == "")) {
if (!(false)) {
?>
<span class="serverInvalidState" id="Log_In_group_user_name_ServerError">Please enter a value.</span>
<?php //WAFV_Conditional login.php login(1,2:)
}
}
}?>
</div>
<div class="lineGroup">
<label for="Log_In_group_2_user_password_hash" class="sublabel" > user_password_hash:<span class="requiredIndicator">&nbsp;*</span></label>
<input id="Log_In_group_2_user_password_hash" name="Log_In_group_2_user_password_hash" type="password" value="" class="formPasswordfield_Medium" tabindex="2" title="Please enter a value." confirm="Log_In_group_user_name" required="true" />
<?php
if (ValidatedField('login','login')) {
if ((strpos((",".ValidatedField("login","login").","), "," . "3" . ",") !== false || "3" == "") || (strpos((",".ValidatedField("login","login").","), "," . "4" . ",") !== false || "4" == "")) {
if (!(false)) {
?>
<span class="serverInvalidState" id="Log_In_group_2_user_password_hash_ServerError">Please enter a value.</span>
<?php //WAFV_Conditional login.php login(3,4:)
}
}
}?>
</div>
<div class="lineGroup">
<label class="checklabel" for="Log_In_group_3_Remember_my_information">
<input type="checkbox" name="Log_In_group_3_Remember_my_information" id="Log_In_group_3_Remember_my_information" value="1" class="formCheckboxField_Standard" <?php if (!(strcmp((isset($_GET["invalid"])?ValidatedField("login","Log_In_group_3_Remember_my_information"):"".(isset($_COOKIE["RememberMe_user_name"])?"1":"") .""),"1"))) {echo "checked=\"checked\"";} ?> tabindex="3" title="Please enter a value" />
&nbsp;Remember my information</label>
</div>
<div class="lineGroup">
<label class="checklabel" for="Log_In_group_4_Log_me_in_automatically">
<input type="checkbox" name="Log_In_group_4_Log_me_in_automatically" id="Log_In_group_4_Log_me_in_automatically" value="1" class="formCheckboxField_Standard" <?php if (!(strcmp((isset($_GET["invalid"])?ValidatedField("login","Log_In_group_4_Log_me_in_automatically"):"".(isset($_COOKIE["AutoLogin_user_name"])?"1":"") .""),"1"))) {echo "checked=\"checked\"";} ?> tabindex="4" title="Please enter a value" />
&nbsp;Log me in automatically</label>
</div>
<span class="buttonFieldGroup" >
<input class="formButton" name="LogIn_submit" type="submit" id="LogIn_submit" value="Log In" onclick="clearAllServerErrors('LogIn_Basic_Default')" tabindex="5" />
</span>
</fieldset>
</form>
</div>
<div id="LogIn_Basic_Default_ProgressMessageWrapper" class="blockUIOverlay" style="display:none;">
<script type="text/javascript">
WADFP_SetProgressToForm('LogIn_Basic_Default', 'LogIn_Basic_Default_ProgressMessageWrapper', WADFP_Theme_Options['BigSpin:Slate']);
</script>
<div id="LogIn_Basic_Default_ProgressMessage" >
<p style="margin:10px; padding:5px;" ><img src="../webassist/progress_bar/images/slate-largespin.gif" alt="" title="" style="vertical-align:middle;" />&nbsp;&nbsp;Please wait</p>
</div>
</div>
</div>
<script src="../webassist/forms/wa_servervalidation.js" type="text/javascript"></script>
<script src="../webassist/jq_validation/jquery.h5validate.js"></script>
<script>
var LogIn_Basic_Default_Opts = {
focusout: true,
focusin: false,
change: false,
keyup: false,
popupClass: "Bloom",
pointedAt: "left",
fieldOffset: 10,
fieldMargin: 2,
position: "left",
direction: "left",
border: 1,
offset: 25,
closeText: "✖",
percentWidth: 100,
orientation: "bottom"
};
function LogIn_Basic_Default_Validate() {
$("#LogIn_Basic_Default").h5Validate(LogIn_Basic_Default_Opts);
}
$(document).ready(function () {
LogIn_Basic_Default_Validate()
ConvertServerErrors(LogIn_Basic_Default_Opts);
});
</script>
</body>
</html>

Sign in to reply to this post

sandy170299

I deleted everything and now tried just creating the login form using Webassist >> Forms >> Insert New Form.

Preset = Log in, Secure Login (I removed the question from the login form, but everything else is as is). This one is redirecting, but as soon as index.php has rules applied to it, it redirects me back to the login page. Also, it doesn't even appear to be interacting with a database table...???

My code is attached.

Thank you.

Sign in to reply to this post

Ray BorduinWebAssist

That is just a form... it doesn't have any of the login server behaviors applied.

To create a login form with login server behaviors you have to use SecurityAssist and not Form Builder.

Sign in to reply to this post
Did this help? Tips are appreciated...
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...