Session variable help
I have a members section which when a member logs in sets a
"session.loggedin" variable equal to 1. On the intial page after
the user logs in I have a link which takes them out of the member
directory and to another page in the root folder of the site. The
session variable works fine when I am on the intial member page and
throughout the members area but when I try to use it on the page in
the root folder it doesnt work. Tells me the session variable does
not exist.
Can some one please explain why this is? I didn't create the
site originally, so I am wondering if there is something I am
missing.
Thanks
See
http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm ?context=ColdFusion_Documentation&file=00001156.htm
"A session refers to all the connections that a single client
might make to a server in the course of viewing any pages
associated with a given application." Your application.cfm at the
root has a name of store and the application one level down has a
name of Members. This is two different applications as indicated by
MikerRoo and won't work the way you want it to.
Ted Zimmerman
Similar Messages
-
Hi, all. I posted questions before when I was stuck, and you
all were very friendly and helpful. I am having difficulty
understanding how to create, POST() to, and then REQUEST()
information stored in session variables using Dreamweaver. I am
developing the pages using PHP, and have a MySQL database uploaded
and working. Displaying, editing, and adding to the database is
ongoing, as I type!
Adobe has thankfully started the session for me with the
<?php if(!isset($_SESSION)) { session_start(); } ... because I
have a log in/log out server behavior on the pages.
I need to add two pieces of information collected from the
page, one value of which is inputted by the user on a form, and the
other value is obtained from values from the part of the recordset
shown on the page. What I expect I need is something like a
2-dimensional array to store both sets as a pair, but while I
expect I can do this, I am really not sure. The documentation ends
before fully explaining this part.
An example of what I am trying to do is a product detail page
from an on-line store catalog, with an "add to cart" button. The
person has navigated to that page, shows the information for
productID=1497 with an input field for quantity, so a person can
order more than one of that product if they choose, and an "add to
cart" button which would write the productID and quantity values to
the session variable. Is there a simple and easy to use Dreamweaver
feature I am missing that can do this?
If I need to code this myself, are there good resources for
figuring this out? What I've found thus far is either too basic, or
too advanced. I've been using Dreamweaver's Insert>Date
Objects> menu to get everything done thus far.
Of course, once the session variables are created I will need
to $_REQUEST() the information on a later page and display it on
one of Dreamweaver's dynamic tables. I hope that once I understand
how to $_POST() the values to the session variable, $_REQUEST()ing
the information on another page will be apparent.
Also, please don't assume I know anything more than what I
wrote in my post. I may be an old school programmer, think punch
cards and FORTRAN, but I can get lost easily on things most people
nowadays think are pretty basic.I got it fixed. It took two weeks to figure out the solution,
but...
It all boils down to the fact that you can get away with
sloppy programming if your MySQL database is located on 'localhost'
that you can't get away with if it is located remotely.
Basically, you need to activate the database before you make
a mysql_query. My bad. Problem solved. And now that I know I need
to do this, problem never rediscovered.
~ Scott
oldcountrypeddler.com -
Unable to fetch session variables in my application page code behind
hi,
my env: 1 WFE server which hosts the central admin and my web appln, 1 sql server box
i am having a custom web part[ listviewbyquery web part] which populates the site collection/ sub site's document library contents . also it reads some query string values and pushes these values into session variables.
and i am having another application page in this application which reads this session variables and perform some operation in a custom sql db. But i am unable to read these session variables on page load of this application page.
am unable to debug also. so, would like to know is there any way i can see, what values are getting passed to this page and verify the session variables are accessed correctly.
or
is this by design, that its not possible to read session variables in the application page ?
if i am not having a visual studio env. to debug, how to test these session variable existence / to find the root cause of this issue.
note: already configured session state in IIS , http modules section. am using Page.Session["myvariable1"].tostring() to fetch the session variables.
help is appreciated!i have found out myself. i have put page.response.write(mysessionvariables) in the code and deployed and tested in my env. and i was able to find out the reason and i have fixed it with proper validation check.
-
Urgent help required...for replacing JSP session variables
I am trying to enhance the performance of a j2ee based webapp which use session variables to store the data...
Is there any alternative for session variables..The project is based on j2ee-Struts frame work..But the amount of code maintainance should be minimum ....so i can't create beanforms for all these data...
Is there any XML based methods available...??ok... thanks... i created a fla file and inthe action script
pasted the following code
var nc:NetConnection = new NetConnection();
nc.connect("rtmp://flash.ispstream.com/ondemand/unikron/my_video_dj/");
var ns:NetStream = new NetStream(nc);
contentMain.myVideo.attachVideo(ns);
ns.setBufferTime(5);
ns.play("dvd_r");
nothing is working if i tried to load... can u help me out -
Need Help With Redirect That Uses Session Variable
I am new to dynamic sites, php, and developer toolbox, but I have been able to create a login site using the different form wizards fairly easily (in CS3 with Developers toolbox).
<br />
<br />I am trying to set a server behavior on a page that redirects the user to a new page if a session variable matches a recordset.
<br />
<br />I was using an extension (PHP Sessions - http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=681308 ) that worked great, but when I installed developers toolbox, it stopped working (get error message about runtime/MX environment).
<br />
<br />Ive been struggling for days and this is what Ive come up with so far:
<br />------------------------------------
<br />session_start();
<br />if (!isset($HTTP_SESSION_VARS[$_SESSION['kt_firstname']]) || $HTTP_SESSION_VARS[$_SESSION['kt_firstname']] = $row_Recordsetfname['firstname']) {
<br /> header ("Location: ../firstname/firstname1.php");
<br />}
<br />------------------------------------
<br />
<br />It redirects regardless of the match. Any ideas on what I can do to get this working? Here is all of the code (with block from above inserted) up until the doc type:
<br />------------------------------------
<br /><?php require_once('../Connections/project1.php'); ?>
<br /><?php<br />// Load the tNG classes<br />require_once('../includes/tng/tNG.inc.php');<br /><br />// Make unified connection variable<br />$conn_project1 = new KT_connection($project1, $database_project1);<br /><br />//Start Restrict Access To Page<br />$restrict = new tNG_RestrictAccess($conn_project1, "../");<br />//Grand Levels: Any<br />$restrict->Execute();<br />//End Restrict Access To Page<br /><br />if (!function_exists("GetSQLValueString")) {<br />function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") <br />{<br /> $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;<br /><br /> $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);<br /><br /> switch ($theType) {<br /> case "text":<br /> $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br /> break; <br /> case "long":<br /> case "int":<br /> $theValue = ($theValue != "") ? intval($theValue) : "NULL";<br /> break;<br /> case "double":<br /> $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";<br /> break;<br /> case "date":<br /> $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br /> break;<br /> case "defined":<br /> $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;<br /> break;<br /> }<br /> return $theValue;<br />}<br />}<br /><br />// FELIXONE - 2002 SB by Felice Di Stefano - www.felixone.it<br />session_start();<br />if (!isset($HTTP_SESSION_VARS[$_SESSION['kt_firstname']]) || $HTTP_SESSION_VARS[$_SESSION['kt_firstname']] = $row_Recordsetfname['firstname']) {<br /> header ("Location: ../firstname/firstname1.php");<br />}<br /><br />$colname_Recordsetfname = "-1";<br />if (isset($_SESSION['kt_user_name'])) {<br /> $colname_Recordsetfname = $_SESSION['kt_user_name'];<br />}<br />mysql_select_db($database_project1, $project1);<br />$query_Recordsetfname = sprintf("SELECT firstname FROM registration WHERE user_name = %s", GetSQLValueString($colname_Recordsetfname, "text"));<br />$Recordsetfname = mysql_query($query_Recordsetfname, $project1) or die(mysql_error());<br />$row_Recordsetfname = mysql_fetch_assoc($Recordsetfname);<br />$totalRows_Recordsetfname = mysql_num_rows($Recordsetfname);<br /><br />$colname_Recordset1 = "-1";<br />if (isset($_SESSION['kt_user_name'])) {<br /> $colname_Recordset1 = $_SESSION['kt_user_name'];<br />}<br />mysql_select_db($database_project1, $project1);<br />$query_Recordset1 = sprintf("SELECT `Date` FROM registration WHERE user_name = %s", GetSQLValueString($colname_Recordset1, "text"));<br />$Recordset1 = mysql_query($query_Recordset1, $project1) or die(mysql_error());<br />$row_Recordset1 = mysql_fetch_assoc($Recordset1);<br />$totalRows_Recordset1 = mysql_num_rows($Recordset1);<br />?>
<br />
<br />------------------------------I am new to adobe toolbox... I ve created a ligin page but not sure how to pass the session variable. I am trying to direct successful login to a page like... index.php?id=filter
<br />
<br />been struggling all day with this. Please help!!!
<br />
<br /><?php require_once('Connections/comm.php'); ?>
<br /><?php<br />// Load the common classes<br />require_once('includes/common/KT_common.php');<br /><br />// Load the tNG classes<br />require_once('includes/tng/tNG.inc.php');<br /><br />// Make a transaction dispatcher instance<br />$tNGs = new tNG_dispatcher("");<br /><br />// Make unified connection variable<br />$conn_comm = new KT_connection($comm, $database_comm);<br /><br />// Start trigger<br />$formValidation = new tNG_FormValidation();<br />$formValidation->addField("kt_login_user", true, "text", "", "", "", "");<br />$formValidation->addField("kt_login_password", true, "text", "", "", "", "");<br />$tNGs->prepareValidation($formValidation);<br />// End trigger<br /><br />// Make a login transaction instance<br />$loginTransaction = new tNG_login($conn_comm);<br />$tNGs->addTransaction($loginTransaction);<br />// Register triggers<br />$loginTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "kt_login1");<br />$loginTransaction->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);<br />$loginTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "{kt_login_redirect}");<br />// Add columns<br />$loginTransaction->addColumn("kt_login_user", "STRING_TYPE", "POST", "kt_login_user");<br />$loginTransaction->addColumn("kt_login_password", "STRING_TYPE", "POST", "kt_login_password");<br />$loginTransaction->addColumn("kt_login_rememberme", "CHECKBOX_1_0_TYPE", "POST", "kt_login_rememberme", "0");<br />// End of login transaction instance<br /><br />// Execute all the registered transactions<br />$tNGs->executeTransactions();<br /><br />// Get the transaction recordset<br />$rscustom = $tNGs->getRecordset("custom");<br />$row_rscustom = mysql_fetch_assoc($rscustom);<br />$totalRows_rscustom = mysql_num_rows($rscustom);<br /><br />?>
<br />
<br />
<br />
<br />
<br />
<br />
<script src="includes/common/js/base.js" type="text/javascript"></script>
<br />
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<br />
<script src="includes/skins/style.js" type="text/javascript"></script>
<br /><?php echo $tNGs->displayValidationRules();?>
<br />
<br />
<br />
<br /><?php<br /> echo $tNGs->getLoginMsg();<br />?>
<br /><?php<br /> echo $tNGs->getErrorMsg();<br />?>
<br />
<form method="post" id="form1" class="KT_tngformerror" action="%3C?php%20echo%20KT_escapeAttribute(KT_getFullUri());%20?%3E">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<table cellpadding="2" cellspacing="0" class="KT_tngtable">
<tr>
<td class="KT_th">
<label for="kt_login_user">Username:</label>
</td>
<td>
<input type="text" name="kt_login_user" id="kt_login_user" value="<?php echo KT_escapeAttribute($row_rscustom['kt_login_user']); ?>" size="32" />
<br /> <?php echo $tNGs->displayFieldHint("kt_login_user");?> <?php echo $tNGs->displayFieldError("custom", "kt_login_user"); ?></td>
</tr>
<tr>
<td class="KT_th">
<label for="kt_login_password">Password:</label>
</td>
<td>
<input type="password" name="kt_login_password" id="kt_login_password" value="" size="32" />
<br /> <?php echo $tNGs->displayFieldHint("kt_login_password");?> <?php echo $tNGs->displayFieldError("custom", "kt_login_password"); ?></td>
</tr>
<tr>
<td class="KT_th">
<label for="kt_login_rememberme">Remember me:</label>
</td>
<td>
<input <?php if (!(strcmp(KT_escapeAttribute($row_rscustom['kt_login_rememberme']),"1"))) {echo "checked";} ?> type="checkbox" name="kt_login_rememberme" id="kt_login_rememberme" value="1" />
<br /> <?php echo $tNGs->displayFieldError("custom", "kt_login_rememberme"); ?></td>
</tr>
<tr class="KT_buttons">
<td colspan="2">
<input type="submit" name="kt_login1" id="kt_login1" value="Login" />
<br /></td>
</tr>
</table>
<br />
<a href="forgot_password.php">Forgot your password?</a>
<br /></form>
<br />
<p> </p>
<br />
<br /> -
Login session variable - pls help before i slot myself
im brand new to this guys and really struggling with logging
in a member to their particular account as opposed to a general
members section using dreamweavers login application and some basic
php coding.
i just cant seem to figure it out it (im stuck on the session
variables i think..) and unfortunately my php is very poor at them
moment!
pls HELP!!
below is the dreamweaver generated code from its basic login
application.
im using it in a dreamweaver template so im not sure if thats
the issue but bascially im using 2 SQL tables i constructed to
achieve this-
1.) tblaccesslevel
intLevelID (unsigned + auto increment + primary key)
txtAccess
(ive allocated various numerical access levels into
txtAccess. ie. 1-7
and
2.) tblplayeraccount
intUserID (unsigned + auto increment + primary key)
txtFirstName
txtLastName
txtEmailAddress
txtPassword
intAccessLevel
(ive generated 2 users in the above table tp test)
in dreameavers server behaviors the recordset generated by
the login server behavior simply says Log In User
obviously i need a session variable somewhere to get the
intUserId....
also a relationship needs to be generated in the sql
statement to connect the intAccessLevel but i think i can manage
that (i think..)
below is the code this application generated -
if someone can give me some hints or if they've done
something similiar pls provide the required code ...it would be a
huge help!! i dont know what im doing wrong!!!
<?php require_once('../Connections/Rugby.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['emailaddress'])) {
$loginUsername=$_POST['emailaddress'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "intAccessLevel";
$MM_redirectLoginSuccess = "../player_home.php";
$MM_redirectLoginFailed = "../failed.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_Rugby, $Rugby);
$LoginRS__query=sprintf("SELECT txtEmailAddress, txtPassword,
intAccessLevel FROM tblplayeraccount WHERE txtEmailAddress='%s' AND
txtPassword='%s'",
get_magic_quotes_gpc() ? $loginUsername :
addslashes($loginUsername), get_magic_quotes_gpc() ? $password :
addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $Rugby) or
die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'intAccessLevel');
//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 );
?>Are you wanting to redirect them to a specific page based on
their username or to the same page with dynamic content based on
their username? -
I am having the same problem as user "Gabe the animator" in a post sent in 2007.
"my recordset that drives a dynamic table won't filter results based on a session variable. I know session variables are working because I have the session variable echo on the page (dragged-n-dropped my session variable from the Bindings panel to my page), and that works fine. So why can't I filter my recordset with the same session variable???"
here is the code:
<?php require_once('Connections/mockconn.php'); ?>
<?php
session_start();
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
return $theValue;
if(!session_id()){
session_start();
$colname_info = "-1";
if (isset($_SESSION['email'])) {
$colname_info = $_SESSION['email'];
mysql_select_db($database_mockconn, $mockconn);
$query_info = sprintf("SELECT name, last_name, email, password FROM registration WHERE email = %s", GetSQLValueString($colname_info, "text"));
$info = mysql_query($query_info, $mockconn) or die(mysql_error());
$row_info = mysql_fetch_assoc($info);
$totalRows_info = mysql_num_rows($info);
?>
<!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>home</title>
</head>
<body>
<div id="info">hello <?php echo $row_info['']; ?></div>
<?php
if (isset($_SESSION['email'])) {
echo 'your email: '.' '. $_SESSION['email'] .' '.'good job';}
?>
</body>
</html>
PLEASE PLEASE HELP.... I have been at this for day's...
how do I get the record set to filter based on the value of the session variableSorry I forgot to mension the error I am getting?
( ! ) Notice: Undefined index: in C:\wamp\www\mock\home.php on line 59
Call Stack
Time
Memory
Function
Location
1
0.0093
389024
{main}( )
..\home.php:0
Why is this error coming up? -
Please Help Session variables disappear
Hi. I am having issues with the developer's version of CF MX
7. I recently set up the developer's version on a test server, and
moved over code from a properly working site using MX 6. I have an
application.cfm file set will the correct <cfapplication> tag
attributes, and the session management is set in the CF admin. When
working on MX 6 the session variables I set were working. Now using
MX 7 none of my sessions are holding. When I first login the
sessions exist, if I click any other page, the variables disappear.
Again, this does not happen on MX 6.
Please help!
Thanks,
jlgDouble-check your sessiontimemout
Try setting up a simple test application using something
similar to the example at
http://livedocs.adobe.com/coldfusion/7/htmldocs/00000217.htm -
Help building an object, setting it in a session variable and casting
Hi all,
I have a problem that I hope you can help me with. The application I am working on has a simple MVC design architecture. The problem occurs when a request is made from the application to the controller servlet. The controller servlet looks at the request type and delegates the processing to the appropriate action and model classes. The model class returns an object of a specific class type that is put into the session variable. This session variable is then cast to the appropriate class type in the jsp that renders that class. The problem is that this particular class type has an array of another class type. The array is filled in the class constructor, but is null when returned to the controller.
At run time when accessing the array I get a NullPointerException error. I can't seem to figure this one out. Any help is greatly appreciated.
Here's the code:
Controller DoPost method. The 'Action' objects are defined and initialized in the init() method.
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException{
try {
HttpSession session = request.getSession();
MemberProfileTbl memProf = (MemberProfileTbl)session.getAttribute("Member");
RequestDispatcher rd;
if (!validateUser(memProf, session)){
session.setAttribute("LoginStatus", "Session Expired");
rd = getServletContext().getRequestDispatcher("/LoginFail.jsp");
rd.forward(request, response);
return;
String act = getAction(request);
Action action = (Action)actions.get(act);
Object result = null;
try {
result = action.perform(request, memProf);
}catch (NullPointerException npx) {
npx.printStackTrace();
session.setAttribute("currObject", result);
rd = getServletContext().getRequestDispatcher("/test/MemberConsole.jsp");
rd.forward(request, response);
catch (Exception ex){
ex.printStackTrace();
Action class:
package accolo.actions;
import javax.servlet.http.*;
import accolo.model .*;
import accolo.view.*;
import accolo.db.MemberProfileTbl;
public class ChangeMainView extends Action {
public String getName() {return "changeMainView";}
public Object perform(HttpServletRequest request, MemberProfileTbl memProf)
throws Exception, ClassNotFoundException, InstantiationException, IllegalAccessException{
Object result;
HMMainView hmMain = new HMMainView(memProf.email);
result = hmMain;
return result;
HMMainView.java class
public class HMMainView
private HMMainViewJob[] jobs;
public String test;
public HMMainView(String email)
HMJobsBean hmJobsBean = new HMJobsBean();
JobTblDao jobTblDao = new JobTblDao();
test = "test in constructor";
try{
JobTbl[] hmJobs = jobTblDao.getHMOpenJobs(email);
for(int j = 0; j < hmJobs.length; j++){
this.jobs[j].jobTitle = hmJobs[j].optionalTitle;
this.jobs[j].city = hmJobs[j].city;
this.jobs[j].state = hmJobsBean.getState(hmJobs[j].zipCode);
Hashtable counts = hmJobsBean.getJSCountsByStatus(hmJobs[j].jobId);
this.jobs[j].unranked = (String)counts.get("CANUNRANKED");
this.jobs[j].interviews = (String)counts.get("HMRI");
this.jobs[j].ranked = (String)counts.get("CANRANKED");
long closed = Long.parseLong((String)counts.get("HMRNI"));
closed += Long.parseLong((String)counts.get("HMCH"));
closed += Long.parseLong((String)counts.get("HMNH"));
this.jobs[j].closed = Long.toString(closed);
}catch(Exception ex){
ex.printStackTrace();
public HMMainViewJob[] getJobs(){ return jobs; }
HMMainViewJob.java class
package accolo.model;
public class HMMainViewJob
public long jobId;
public String jobTitle;
public String status_id;
public String city;
public String state;
public String unranked;
public String interviews;
public String ranked;
public String closed;
public HMMainViewJob()
Snippet of JSP that uses the code
Object result = session.getAttribute("currObject");
if (result != null){
String className = result.getClass().getName();
if (className.equals("accolo.model.HMMainView")){
header = "HM/HMConsoleHeader.jsp";
subNav = "HM/HMConsoleSubNav.jsp";
user = "HM/HMConsoleUser.jsp";
left = "HM/HMConsoleLeft.jsp";
// body = "HM/HMConsoleHome.jsp";
HMMainView hmMain = (HMMainView) result;
HMMainViewJob[] jobs = hmMain.getJobs();
for (int i = 0; i < jobs.length; i++){
%>
Jobs: <%=jobs.jobTitle%>
<%I have not run this through a debugger yet. I don't have immediate access to a debugger to run it through, most of the development is simply done in vi. I was hoping any problem in the code would jump out at someone. I've been staring at it too long.
I'll try to get a debugger set up.
Thanks -
Help with php session variables
I am using Dreamweaver 8 to set up a dynamic app with PHP and
MySQL. I want the code that the user logs in with ('UPN') to be
stored as a session variable so that recordsets on subsequent pages
can be set to display personalised data.
I have set the session variable like this: $_SESSION['UPN'] =
'UPN' (UPN is the name of the form textfield, also set as the
username for logging in)
On the data page, I have called the variable like this:
$query_Recordset1 = ("SELECT pupils.pupilID, pupils.UPN,
pupils.forename, pupils.surname FROM pupils WHERE UPN = '" .
$_SESSION['UPN'] . "'");
The recordset returns nothing- the dynamic table returns ony
the column headings (both as headings and immediately under where
you would expect the data to be).
Can anyone help?
ThanksOn Wed, 17 Oct 2007 11:43:04 +0000 (UTC), "denman"
<[email protected]> wrote:
> I have set the session variable like this:
$_SESSION['UPN'] = 'UPN' (UPN is
>the name of the form textfield, also set as the username
for logging in)
Your code assigns the literal string UPN to the session
variable. If
it's coming from POSTed form data, you'd need to do it like:
$_SESSION['UPN'] = $_POST['UPN'];
Gary -
Dreamweaver need to create a session variable or Cookie or something Help
I have been working for weeks I am very close but can't get over one last hurdle. I am trying to call a session variable much like dreamweaver calls mm_username. It is in the same user table as username - password - access level - Customer_id. I need to pull the session variable or cookie or however I can do it to access the customer id number so I can have customer specific information and pricing. There will be mulitple users for each customer so I need another variable besides mm_username. Help I use dreamweaver cs4 aspvbscript and sqlserver ...help
I soon as I put the red line of code in it is custoemr _id instead of user id in my table. Dreamweaver removes the user id function. is it in the wrong place ...what am i doning wrong ....it is fine with the first part you did but the second part it doesnt like in red.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include virtual="/Connections/p21.asp" -->
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString <> "" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername = CStr(Request.Form("username"))
If MM_valUsername <> "" Then
Dim MM_fldUserAuthorization
Dim MM_redirectLoginSuccess
Dim MM_redirectLoginFailed
Dim MM_loginSQL
Dim MM_rsUser
Dim MM_rsUser_cmd
MM_fldUserAuthorization = "Access_Level"
MM_redirectLoginSuccess = "/mainmenu.asp"
MM_redirectLoginFailed = "/loginfailed.asp"
MM_loginSQL = "SELECT customer_id, Login_Name, password"
If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
MM_loginSQL = MM_loginSQL & " FROM dbo.btb_web_login WHERE Login_Name = ? AND password = ?"
Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command")
MM_rsUser_cmd.ActiveConnection = MM_p21_STRING
MM_rsUser_cmd.CommandText = MM_loginSQL
MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param1", 200, 1, 20, MM_valUsername) ' adVarChar
MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param2", 200, 1, 10, Request.Form("password")) ' adVarChar
MM_rsUser_cmd.Prepared = true
Set MM_rsUser = MM_rsUser_cmd.Execute
If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
Session("MM_Username") = MM_valUsername
Session ("MM_USERID") = MM_rsUser.Fields.Item("customer_id").value
If (MM_fldUserAuthorization <> "") Then
Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
Else
Session("MM_UserAuthorization") = ""
End If
if CStr(Request.QueryString("accessdenied")) <> "" And false Then
MM_redirectLoginSuccess = Request.QueryString("accessdenied")
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If
%><!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>Brown Live Online Login</title>
<style type="text/css">
<!--
body {
background-image: url(/images/gradientblacktowhite.jpg);
background-repeat: repeat-x;
.style1 {
color: #FFFFFF;
font-weight: bold;
.style3 {color: #000000; font-weight: bold; }
.style5 {
font-size: xx-large;
color: #0000FF;
.style6 {color: #000000}
-->
</style></head>
<body>
<p class="style5"><img src="/images/BTBlogosmall.jpg" width="322" height="53" /></p>
<p class="style5">Brown Live Online 2.0 </p>
<form ACTION="<%=MM_LoginAction%>" id="form1" name="form1" method="POST">
<p>
<label><span class="style3"> User Name</span>
<input name="username" type="text" id="username" size="20" />
</label>
</p>
<p>
<label><span class="style1"><span class="style6">Password</span></span>
<input name="password" type="password" id="password" size="20" />
</label>
</p>
<p>
<label>
<input type="submit" name="button" id="button" value="Login" />
</label>
</p>
</form>
<p><a href="/index.html"><img src="/images/brown2.0.jpg" width="100" height="100" /></a> Click Image to return to <a href="http://www.browntransmission.com">www.browntransmission.com</a></p>
</body>
</html> -
Help Needed in checking session variable
In a sample site, I am calling a bounded task flow from an unbounded task flow. In the called taskflow the default activity is a router which checks the session variable, and the home page will be loaded only if the session variable is not null. If session variable is null router will lead to a page dispalying 'session expired'. But even after clearing the session if I copy pasted the previous url, the home page is loading. But when I call bounded taskflow from a bounded taskflow, it is working fine. Can anyone suggest any solution? Thanks in advance
Thanks for the reply. I'm using jdev 11.1.1.5.0.. I'm just trying with a sample example. I have a login page and when the user logins, the user name is stored in session. the loginpage view activity is in adfc config unbounded taskflow. The login credentials is validated in a backing bean and based on the return value, if the login is valid, a bounded taskflow 'hometaskflow' is called. In this bounded taskflow, the default activity is a router wchich checks the username stored in session. If the username is not null it will lead to the 'homepage' view. Else if it is null it will lead to a 'sessionexpired' view.
In the java class of login page I'm accessing the session variable as shown
public Username getSessionBean()
Username username =
(Username)resolveExpression("#{Username}");
return username;
public static Object resolveExpression(String expression)
FacesContext facesContext = FacesContext.getCurrentInstance();
Application app = facesContext.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = facesContext.getELContext();
ValueExpression valueExp =
elFactory.createValueExpression(elContext, expression,
Object.class);
return valueExp.getValue(elContext);
On login button click the function being executed is as shown
public String onLoginClick() {
if(String.valueOf(itUserName.getValue()).equals("admin")
&& String.valueOf(itPassword.getValue()).equals("admin"))
Username username=getSessionBean();
username.setUsername(itUserName.getValue().toString());
return "success";
else {
return "invalid";
And to set username as null on logout, I used this function on logout click
public void clearSession()
Username username=getSessionBean();
username.setUsername(null);
The EL expression used to check the value of session variable is
#{sessionScope.Username.username==null} outcome is expired
#{sessionScope.Username.username!=null} outcome is active
This worked when I used in a bounded taskflow, which is being called from another bounded taskflow. But not working in this scenario... -
Help with session variable please - CS5.5 PHP
Hi all,
I am needing a little assistance with using a session variable and hope that someone may point me in the right direction.
I have created a PHP page that uses the Dreamweaver 'User Authentication' feature, and the basics of this works fine, directing a user to the correct pages depending on whether they are or are not a valid user. I would like however to personalise the 'valid user' page with the persons Username as entered in the User Authentication table....a seemingly simple task using a session variable, but one that I just don't seem to be able to get working!
The code generated for the UA on page 1 is as follows:
<?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['txtfirst_name'])) {
$loginUsername=$_POST['txtfirst_name'];
$password=$_POST['txtsurname'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "member_update.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_panto, $panto);
$LoginRS__query=sprintf("SELECT firstname, surname FROM web_access WHERE firstname=%s AND surname=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $panto) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//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 );
?>
Firstly, the text highlighted in red above appears to be setting the session variable that I require. Is This correct?
If so, what is the code that I need to place in page 2 to use that session variable? or
Do I need to do something else on page 1 to properly assign the session variable?
Would really appreciate your expertise
MarkIt looks as though you've set the columns incorrectly in the User Authentication server behavior. This is the SQL query that checks the user's credentials:
$LoginRS__query=sprintf("SELECT firstname, surname FROM web_access WHERE firstname=%s AND surname=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
You're looking for firstname and surname, whereas you should be looking for the user's login name and password.
$_SESSION['MM_Username'] is a session variable that stores the user's login name. To use it in a subsequent page, all that's needed is for the page to begin with session_start(). You can then echo the value to display it.
If you want to display the person's real name, you need to create a recordset in the second page using $_SESSION['MM_Username'] to find the firstname and surname. Alternatively, you can edit the existing code like this (I've copied only part of it):
$LoginRS__query=sprintf("SELECT firstname, surname FROM web_access WHERE firstname=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $panto) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
$row = mysql_fetch_assoc($LoginRS);
$_SESSION['full_name'] = $row['firstname'] . ' ' . $row['surname'];
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
You can then use $_SESSION['full_name'] in a subsequent page that begins with session_start(). -
To pass new session variable value to stored proc before running a report.
Hi,
Below is summary of the report requirement -
Database level design
1. Created a view and a global temporary table (GTT)
2. Created an Oracle package procedure to accept from and to business dates on basis of which it will fetch, process and populate the GTT.
Repository level design
1. Created a business model containing the view and the GTT (mentioned above)
2. Created two SESSION variables "from_dt" and "to_dt" to be initialized by their respective init blocks. Each of the variable is initialized with a DATE column value (of type DATETIME) from a database lookup table. I have also set the option "Enable that variable to be set by any user" for both variables.
Query for these variables :
from_dt = select from_date from <table>
to_dt = select add_months(from_date,12) from <table>
Presentation level design
1. Using a text box, i display the default/initialized values of these variables like this -
Current business date:@{biServer.variables['NQ_SESSION.from_dt']} Future business dt:@{biServer.variables['NQ_SESSION.to_dt']}
Dates get displayed in YYYY-MM-DD 00:00:00 format
The text msg displays these default dates and allows the user to specift different date range for which i create prompts as shown below.
2. Using any random two columns of date type from the business model, i create two date dashboard prompts with labels "From Dt" and "To Dt".
i select Calender Controls for both; setting Default To = Report Defaults.
The Set Variable is set to Presentation variables - such that pv_from_dt maps to "From Dt" and pv_to_dt maps to "To Dt".
3. i create the report using the business model created above. In the report "Advanced Tab" => "Prefix" field i specify the following -
SET VARIABLE from_dt='@{pv_from_dt}',to_dt='@{pv_to_dt}';
Note : The logic here is to display the default dates and allow user to specify different date values which will be stored in presentation variables.
If the user does specify different "from dt" and "to dt" values, then using the presentation variables, i want to "write" back these new values to the corresponding session variables mentioned above.
If the user does not specify different date range, then the default/initialized dates must be considered.
I also display the default and new date values in the report title.
Back to Repository level design
To execute the stored procedure that will load the GTT before running the report I need to pass two date parameters to the stored procedure on basis of which it will fetch data, process and populate the GTT.
In the Connection Pool --> Connection Script Tab --> Execute before query, I wrote the below query using the repository variables FROM_DT and TO_DT to execute the procedure -
DECLARE
v_from_dt date;
v_to_dt date;
BEGIN
v_from_dt := VALUEOF(From_Dt);
v_to_dt := VALUEOF(To_Dt);
package_name1.package_body(v_from_dt,v_to_dt);
END;
Now when i try to run the report i get the following error :
[nQSError: 10058] A general error has occurred. [nQSError: 23006] The session variable, NQ_SESSION.to_dt, has no value definition. (HY000)..
Need help on this.
Is it possible to "write back" a new value to a session variable ?
Any other alternatives.
Thanks
Nusrat
Edited by: user10309945 on Jan 24, 2011 10:08 PMSandeep, I found a several topics where users describe saving values in DB through stored procedure or function. For example, [How to store OBIEE presentation level variable values in DB |http://forums.oracle.com/forums/thread.jspa?threadID=892006] I tried it and get an error
*10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 14551, message: ORA-14551: cannot perform a DML operation inside a query ORA-06512*
It's not a BI error. This error are generated by Oracle DB. If I write next:
SELECT MyPLSQLFunction(p1,p2) FROM DUAL
I get the same error.
Oracle doesn't allow DML operations in SELECT.
Did you relalize this feature yourself? Where did I mistake? -
Trying to move a list of form variables to session variables of the same name
I am trying to move a list of form variables to session variables of the same name and I am having a lot of trouble.
I have never had to post of this forum with a language question in all the 10 years I have been using ColdFusion. I was a qa Engineer @ Allaire/Macromedia back when it was going from one to the other. I have a pretty good grasp of the language.
I have software that runs off a list. The fieldnames are variable and stored off in an array. It's survey software that runs off a "meta file". In this example; I have the number of fields in the survey set to 12 in the "metafile". I have each field declared in that file in array Session.SurveyField[1] and the above loop works fine. I include this "metafile" at the start of the process.
I cfloop around a struct and it works wherever I have needed to use it; such as here - writing to the database for example;
<CFQUERY NAME="InsertRec" DATASOURCE="Survey">
INSERT into #variables.SurveyTableName#
(EntryTime
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
,#Session.SurveyField[arrayindex]#
</cfloop>
<!--- EXAMPLE OF WHAT THE ABOVE GENERATES
,q01_name,q02_AcadTechORNA,q03_Water,q04_FirstAid,q05_CPR,q06_LifeGuard,q07_AED
,q08_ProjAdv,q09_Color,q10_SantaClaus,q11_Supervisor,q12_SupervisorOpinion --->
VALUES
('#EntryTime#'
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset thisname = "Session." & Session.SurveyField[arrayindex]>
,'#evaluate(variables.thisname)#'
</cfloop>
<!--- EXAMPLE OF WHAT THE ABOVE GENERATES
,'#Session.q01_name#','#Session.q02_AcadTechORNA#','#Session.q03_Water#','#Session.q04_Fi rstAid#'
,'#Session.q05_CPR#','#Session.q06_LifeGuard#','#Session.q07_AED#','#Session.q08_ProjAdv# ',
,'#Session.q09_Color#','#Session.q10_SantaClaus#','#Session.q11_Supervisor#','#Session.q1 2_SupervisorOpinion#' --->
</CFQUERY>
NOW HERE'S THE PROBLEM: I am running into trouble when trying to move the form variables to session variables of the same name. It is the only part of the software that I still need the datanames hard coded and that is a roadblock for me.
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset thissessionfield = "Session." & Session.SurveyField[arrayindex]>
<cfset thisformfield = "Form." & Session.SurveyField[arrayindex]>
<cfset #thissessionfield# = #evaluate(thisformfield)#>
</cfloop>
I have tried it with or without the "evaluate"; same result. It doesn't give an error; it just ignores them (session variables look as such in the next page in the chain)
q01_name=
q02_acadtechorna=
q03_water=
q04_firstaid=
q05_cpr=
q06_lifeguard=
q07_aed=
q08_projadv=
q09_color=
q10_santaclaus=
q11_supervisor=
q12_supervisoropinion=
Note: they exist because I CFPARAM them in a loop like the above at the start of the procedure) - and this works just fine!
<cflock scope="Session" type="EXCLUSIVE" timeout="30">
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset dataname = "Session." & Session.SurveyField[arrayindex]>
<cfparam name="#variables.dataname#" default="">
</cfloop>
</cflock>
I EVEN tried exploiting the Form.Fieldnames list using CFLoop over the list and the same sort of logic within and it still gives me nothing....
Here's the FORM.FIELDNAMES value
"Q01_NAME,Q02_ACADTECHORNA,Q03_WATER,Q04_FIRSTAID,Q05_CPR,Q06_LIFEGUARD,Q07_AED,Q08_PROJAD V,Q09_COLOR,
Q10_SANTACLAUS,Q11_SUPERVISOR,Q12_SUPERVISOROPINION"
Here's the logic; SAME RESULT - The session variables don't get set.
<cfoutput>
<cfloop list="#Form.FieldNames#" index="thisfield">
<!--- <br>#thisfield# --->
<cfscript>
thisSESSIONfield = "Session." & thisfield;
thisFORMfield = "Form." & thisfield;
#thisSESSIONfield# = #thisFORMfield#;
</cfscript>
</cfloop>
</cfoutput>
The CFPARAM in a loop with variable output name works just fine; so does the post (which I included above) as does the SQL Create, Param Form Variables, Param Session Variables, etc.
THIS even works for moving BLANK to each session variable, to zero them all out at the end of the process;
<cflock scope="Session" type="EXCLUSIVE" timeout="30">
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset thislocalfield = Session.SurveyField[arrayindex]>
<cfscript>
thissessionfield = "Session." & thislocalfield;
</cfscript>
<cfset #thissessionfield# = "">
</cfloop>
</cflock>
Expanding on that code, you would think this would work, but it doesn't;
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset thislocalfield = Session.SurveyField[arrayindex]>
<cfscript>
thissessionfield = "Session." & thislocalfield;
thisformfield = "Form." & thislocalfield;
</cfscript>
<!--- debug --->
<!--- <cfoutput>#thissessionfield# = "#evaluate(thisformfield)#"</cfoutput><br> --->
<cfoutput>
<cfset #thissessionfield# = "#evaluate(thisformfield)#">
</cfoutput>
</cfloop>
And see that debug code in the middle? To add insult to injury... When I uncomment that it shows me this. So it certainly looks like this should work....
Session.q01_name = "Me"
Session.q02_AcadTechORNA = "N/A"
Session.q03_Water = "Yes (certificate expired)"
Session.q04_FirstAid = "Yes (certificate is current)"
Session.q05_CPR = "No"
Session.q06_LifeGuard = "Yes (certificate expired)"
Session.q07_AED = "Yes (certificate expired)"
Session.q08_ProjAdv = "Yes (certificate expired)"
Session.q09_Color = "Gray"
Session.q10_SantaClaus = "Yes"
Session.q11_Supervisor = "Da Boss"
Session.q12_SupervisorOpinion = "Not a bad thing"
There must be some simpler way to do this. This way won't work against all odds even though it seems so much like it should.
So I end up having to hardcode it; still looking for an automated way to set these #@%$*@!## session variables over the list from the form variables of the same @#@!$#%$%# name. Do I sound frustrated???
No matter what I do, if I don't HARDCODE like this;
<cfset Session.q01_name = Form.q01_name>
<cfset Session.q02_AcadTechORNA = Form.q02_AcadTechORNA>
<cfset Session.q03_Water = Form.q03_Water>
<cfset Session.q04_FirstAid = Form.q04_FirstAid>
<cfset Session.q05_CPR = Form.q05_CPR>
<cfset Session.q06_LifeGuard = Form.q06_LifeGuard>
<cfset Session.q07_AED = Form.q07_AED>
<cfset Session.q08_ProjAdv = Form.q08_ProjAdv>
<cfset Session.q09_Color = Form.q09_Color>
<cfset Session.q10_SantaClaus = Form.q10_SantaClaus>
<cfset Session.q11_Supervisor = Form.q11_Supervisor>
<cfset Session.q12_SupervisorOpinion = Form.q12_SupervisorOpinion>
I always get this from my next page because the session variables are empty;
You must answer question 1.
You must answer question 2.
You must answer question 3.
You must answer question 4.
You must answer question 5.
You must answer question 6.
You must answer question 7.
You must answer question 8.
You must answer question 9.
You must answer question 10.
I tried duplicate as well, but I can not get the above to work...
Can anyone help me do this thing that one would think is simple????I think if you use structure array syntax you should get the results you want.
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset session[Session.SurveyField[arrayindex]] = Form[Session.SurveyField[arrayindex]]>
</cfloop>
Or probably even easier.
<cfset session = duplicate(form)>
Maybe you are looking for
-
Adobe Reader 10.1.1 will not open .pdfs
Adobe was working just fine when I was using it earlier this morning until I logged off to let another employee briefly use my computer. Since then I keep receiving an error message that says "Adobe Reader has encountered a problem and needs to clos
-
IMovie transitions issue with retina mac?
Does anyone have an issue with adding transitions in a video in iMovie on the 13" RETINA macbook pro? I have imported a .mov file and I can't put transitions between the video. iMovie starts to do this weird thing where it shortens the video and disp
-
Connection with serial device (SPP)
I try to connect with a bluetooth serial device (a robot, no standard device) which is working with every PC but not from my MAC. I can connect to the device (I use ZTerm) and send one character, but not more. If I send more, those characters are not
-
Developer 6.0 vs. JDeveloper
Can someone clear up a little confusion I have about Jdeveloper and Developer 6.0. We want to create a front-end application based off of forms and deploy that application on the web through a browser. I know that I can do this with Developer 6.0 ser
-
IStore Account & Payment Information
Hi everyone ! i'm not sure to post my problem in this subforum ... but here i go. Today i have registered my iPod 4G from the website (not from iTunes)... after finishing my registration and trying to log on iTunes to download some free apps it says