?
Solved

Element is undefined in session??

Posted on 2003-03-20
8
Medium Priority
?
352 Views
Last Modified: 2013-12-24
I am trying to use some session variables.  Sometimes they work and other times I get that the element is undefined in session.  What am I doing wrong?

This is where I have my session variables defined:

               <CFSET SESSION.LOGGEDIN = TRUE>
               <CFSET session.userid = checkuser.userid>
               <cfset session.username = checkuser.username>
               <cfset session.accountnbr = checkuser.accountnbr>

I call them in my main menu screen, to only get the systems that they have access to show on the main menu screen.

<cfquery datasource="database" name="getuseraccess">
select
  useraccess.systemcode,
  useraccess.systemaccess,
  system,
  image,
  location
from useraccess inner join system on useraccess.systemcode = system.systemcode
where
  (userid = #session.userid# and
  systemaccess = 'yes')
</cfquery>


Then I call the session userid within my directory in another Application.cfm file to verify that the user has access to that file, incase they bypass the login screen.

<cfquery name="usersec" datasource="database">
SELECT
  userid,
  systemaccess,
  systemcode
FROM UserAccess
WHERE (UserId = #session.userid#
 and UserAccess.SystemCode = 3)
</cfquery>


The session.userid variable works for my mainmenu, but not in the Application.cfm file.  Does anyone know what I am doing wrong?  
0
Comment
Question by:swartout
8 Comments
 
LVL 9

Expert Comment

by:HamdyHassan
ID: 8174301
Are you using CFMX or CF4 , CF5 ?
Also show content of application.cfm
0
 

Author Comment

by:swartout
ID: 8174401
I am using CFMX that came with Studio MX.


This is my Application.cfm in my root directory.  I actually have my session variables defined in another file.  Maybe that is my problem.

<CFAPPLICATION NAME="Login" SESSIONMANAGEMENT="Yes" clientmanagement="yes">

This is my Application.cfm in my useradmin directory.

<CFAPPLICATION NAME="login" SESSIONMANAGEMENT="Yes" clientmanagement="yes">


<cfquery name="usersec" datasource="database">
SELECT
  userid,
  systemaccess,
  systemcode
FROM UserAccess
WHERE (UserId = #session.userid#
 and UserAccess.SystemCode = 3)
</cfquery>

<cfoutput query="usersec">
<cfif not isdefined("useraccess.userid")>
<p>You do not have access to perform this function.</p>
<p><a href="../login/mainmenu.cfm">Return to Main Menu</a></p>
</cfif>
</cfoutput>

0
 
LVL 10

Expert Comment

by:substand
ID: 8174424
you mentioned that your application.cfm is in a different directory.  did you make sure to name the applications the same in both directories?

<cfapplication name="name1"...> in application.cfm in directory 1.

and

<cfapplication name="name1"...>in application.cfm in directory 2.


 
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:swartout
ID: 8174688
Yes, they are named the same in both directories.
0
 
LVL 8

Accepted Solution

by:
TallerMike earned 1000 total points
ID: 8174838
Although in this case you pasted that one is named with an uppercase 'Login' and the other with a lower case 'login'...

You should not be recreating the entire application.cfm file in the useradmin directory. You should include the Application.cfm file from root like so:

<cfinclude template="../Application.cfm">

And have the application setup ONLY in the Application.cfm from the root.

Of course these are just suggestions really and may not fix your problem. But who knows?
0
 

Author Comment

by:swartout
ID: 8174945
Thanks, it works now.
0
 
LVL 8

Expert Comment

by:TallerMike
ID: 8175105
Which did you change to get it to work? Match the application names case? Or did you include the Application.cfm? Just so I know what to do/say when I see this again.
0
 

Author Comment

by:swartout
ID: 8175207
I included the Application.cfm.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question