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