?
Solved

Element is undefined in session??

Posted on 2003-03-20
8
Medium Priority
?
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

 

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

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

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

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

762 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