CF - If statement not reacting to session role

I am trying to have one of two include files used by the program based on the session user role.  The if statement is

<cfif isDefined("SESSION.Role")eq 0>
<cfinclude template="sidebar_menuUser.cfm">
<cfelse>
<cfinclude template="sidebar_menuAdmin.cfm">
</cfif>

The problem is users are seeing the admin menu sidebar.

Any help is appreciated
JohnMac328Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Andrew MaurerCommented:
try
<cfif isDefined("SESSION.Role")>
<cfinclude template="sidebar_menuUser.cfm">
<cfelse>
<cfinclude template="sidebar_menuAdmin.cfm">
</cfif>

OR if you mean it is not defined

<cfif NOT isDefined("SESSION.Role")>
<cfinclude template="sidebar_menuUser.cfm">
<cfelse>
<cfinclude template="sidebar_menuAdmin.cfm">
</cfif>

Open in new window

0
JohnMac328Author Commented:
There is a role defined which is either a value of 0 which is user or 1 which is Admin.  Here is what is at the top of the login page, does a part of this also need to be in every page?

<CFIF CHECK_USER.RECORDCOUNT GT 0>
  <CFSET SESSION.LoggedIn="Yes">
  <CFSET SESSION.EmployeeID=CHECK_USER.EmployeeID>
  <CFSET SESSION.Role=CHECK_USER.role>
0
Andrew MaurerCommented:
then..
<cfif isDefined("SESSION.Role") AND SESSION.Role EQ 0 >
<cfinclude template="sidebar_menuUser.cfm">
<cfelse>
<cfinclude template="sidebar_menuAdmin.cfm">
</cfif>

Open in new window

0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Andrew MaurerCommented:
Im not sure if you need it on every page.. if you did, I would say you'd want it in app cfc or app cfm
0
JohnMac328Author Commented:
Still not working, here is what is in the application.cfm, the employee table has a 'role' field with either 0 or 1, is check_user a CF defined term?  I am updating a program written by someone else.
<cfif structKeyExists(form,"Password")>
   
    <cfquery name="check_user" datasource="#datasource#">
           SELECT EmployeeID, Role FROM Employees
 WHERE Email = '#Form.Email#'
 AND Password = '#Form.Password#'
    </cfquery>

    <!-- <cfif check_user.recordcount is not 0>
        <!-- Log them in with a timeout of 30 minutes (1800 sec) and set level of Admin-->
        <cflogin idletimeout="1800">
            <cfloginuser 
                    name = "#FORM.Email#"
                    password ="#FORM.Password#"
                    roles = "#check_user.Role#">
        </cflogin>
    <cfelse>
        <!-- If an invalid Login Attemp, Set invalid to 1 for invalid login script -->
        <cfset invalid_login = 1>
    </cfif>
</cfif>

Open in new window

0
Andrew MaurerCommented:
Im not exactly sure how your login sctructure is setup. Can you do

<dump var="#session#">

above this line..

<cfif isDefined("SESSION.Role") AND SESSION.Role EQ 0 >

Roles could be a list..
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JohnMac328Author Commented:
It saw my role as being 1 which is correct, and saw the user as 0 which is correct.  For some reason the if statement is not being observed.

employeeid 231  
loggedin Yes  
role 1  
sessionid f030fca1e861ef4f9f511953372375b1f692  
urltoken CFID=8400&CFTOKEN=89814093&jsessionid=f030fca1e861ef4f9f511953372375b1f692
0
Andrew MaurerCommented:
curious... Unix box?

another way tot test is put a dump in each of the  if sections


<cfif isDefined("session.role") AND session.role EQ 0 >
<cfinclude template="sidebar_menuUser.cfm">
<cfelse>
<cfinclude template="sidebar_menuAdmin.cfm">
</cfif>

TEST 
<cfif isDefined("session.role") AND session.role EQ 0 >
ROLE EQ 0<BR/>
<cfelse>
ROLE EQ ELSE<BR/>
</cfif>

Open in new window

0
JohnMac328Author Commented:
Forgot to transfer this to the other pages, seems to work fine now.

Thanks for your help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.