close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How do I add a session variable / value without it being part of the "storeResult" command @ login

Thread began 6/02/2021 11:26 am by NavyChief | Last modified 6/02/2021 2:38 pm by Ray Borduin | 442 views | 5 replies |

NavyChief

How do I add a session variable / value without it being part of the "storeResult" command @ login

I have read a few of the threads on this and it "seems" my situation is a bit different. I cant seem to save session values from page to page if they are NOT stored using the "storeResult" command during login AND I cant even change the existing session values either. When users log in the login table has the values needed for the rest of the pages; however, admins log in in have no values because they should be able to choose a value and that part does not work.

In the example below I am altering the session variables based on selection from a form but I also want to add session vars outside of the login "storeResult" command.

LOGIN.PHP
<?php @session_start(); ?>
<?php require_once('/removed/Connections/conWEBPRO.php'); ?>
<?php require_once('/removed/webassist/mysqli/authentication.php'); ?>
<?php require_once('removed/webassist/mysqli/queryobj.php'); ?>
<?php require_once('/removed/webassist/mysqli/rsobj.php'); ?>
<?php
$Authenticate = new WA_MySQLi_Auth($conWEBPRO);
$Authenticate->Action = "authenticate";
$Authenticate->Trigger = ((((isset($_POST["un"]))?$_POST["un"]:"") != ""));
$Authenticate->Name = "username";
$Authenticate->Table = "security";
$Authenticate->addFilter("username", "=", "s", "".((isset($_POST["un"]))?$_POST["un"]:"") ."");
$Authenticate->addFilter("password", "=", "s", "".((isset($_POST["pw"]))?$_POST["pw"]:"") ."");
$Authenticate->storeResult("idx", "widx");
$Authenticate->storeResult("admlvl", "lvl");
$Authenticate->storeResult("username", "unm");
$Authenticate->storeResult("password", "upw");
$Authenticate->storeResult("email", "em");
$Authenticate->storeResult("wed_name", "wnm"); // <= initially saved here
$Authenticate->storeResult("wed_key", "wky"); // <= initially saved here
$Authenticate->storeResult("validated", "val");
$Authenticate->RememberMe = (true);
$Authenticate->SaveLogin = (true);
$Authenticate->AutoReturn = false;
$SuccessRedirect = "main.php?wk=".$_POST['wk'];
$FailedRedirect = "failure.php";
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();
?>
{more after}

MAIN.PHP
<?php @session_start(); ?>
<?php require_once('/removed/Connections/conWEBPRO.php'); ?>
<?php require_once('/removed/webassist/mysqli/authentication.php'); ?>
<?php require_once('/removed/webassist/mysqli/queryobj.php'); ?>
<?php require_once('/removed/webassist/mysqli/rsobj.php'); ?>
<?php
if (true) {
$RestrictAccess = new WA_MySQLi_Auth();
$RestrictAccess->Action = "restrict";
$RestrictAccess->Name = "username";
$RestricAccessRedirect = "login.php";
if (function_exists("rel2abs")) $RestricAccessRedirect = $RestricAccessRedirect?rel2abs($RestricAccessRedirect,dirname(__FILE__)):"";
$RestrictAccess->FailRedirect = $RestricAccessRedirect;
$RestrictAccess->execute();
}

?>
<?php
if ($_SESSION['val'] <> 0) { header("Location: noval.php"); }
?>
<?php
if (($_SESSION['lvl'] == 9) && (isset($_GET['wk']))) {
$rsWEDLIST = new WA_MySQLi_RS("rsWEDLIST",$conWEBPRO,1);
$rsWEDLIST->setQuery("SELECT wed_name, wed_key FROM security WHERE wed_key = '".$_GET['wk']."' GROUP BY wed_name, wed_key ORDER BY wed_name ASC");
$rsWEDLIST->execute();
$_SESSION['wnm'] = ($rsWEDLIST->getColumnVal("wed_name")); // <= value changed here
$_SESSION['wky'] = ($rsWEDLIST->getColumnVal("wed_key")); // <= value changed here
}
?>
{mopre after}

All other pages (example wlist.php) where $_SESSION['wnm'] and $_SESSION['wky'] are referenced show the stored value from login EXCEPT main.php shows the new values as if they are separate session vars.

I think somehow I need to get the session index key and provide it when I save other session vars post login.

Thoughts

Eric Joy

Sign in to reply to this post

Ray BorduinWebAssist

You probably just have to add:

@session_start();

before your code that resets the session variables. The webassist code closes the session once it is done, so you would have to re-start it in order to overwrite any values.

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

NavyChief

I am sorry but did you look closely.... I have @session_start();.... you did not see it??

Take a closer look at the attachments and/or my text above...

Sign in to reply to this post

Ray BorduinWebAssist

Yes, but it is above our code... We close the session once we are done. You need to open it again directly above your code that sets the session value.

The one you have on top is unnecessary since we open the session in the connection and authentication code, but we close it when we are done. That leaves it closed by the time your code runs.

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

NavyChief

I moved it there as a test... it was below the require_once's previously so I am clueless what you are talking about.

I have had it above at the top and below the last require once... I am confused as to where to put them.

Sign in to reply to this post

Ray BorduinWebAssist

@session_start() // <--- Put it here
$_SESSION['wnm'] = ($rsWEDLIST->getColumnVal("wed_name")); // <= value changed here
$_SESSION['wky'] = ($rsWEDLIST->getColumnVal("wed_key")); // <= value changed here

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

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...