I developed a few pages to restrict access by way of a username and password login. I keep getting an error that says my session variable "login" is undefined. here is the code in question, though it might be more so on another page.

<cfif SESSION.login EQ "No">
<cflocation url="adminLogin.cfm" addtoken="no">
</cfif>

I have a cfinclude template on each page I want to restrict access to.

Some help would be greatly appreciated. Thanks in advance!

Tony

Recommended Answers

All 10 Replies

Where are you setting the session variables? I'd also check the obvious things like is sessionManagement enabled in the application.cfm/cfc.

IIRC, there used to be an issue with setting session variables and using cflocation on the same page. Don't know if it still applies though.

I'm no expert but I think you may just need to cfparam SESSION.login with a default value of "no" <cfparam name="SESSION.login" default="no"> in your Application.cfm. I've personally found no problem using session vars and cflocation in this way, the only problem I can think of with cflocation is that you can't append URL vars to the cflocation URL, but you can append session vars....I could be wrong though ;-)

Where are you setting the session variables? I'd also check the obvious things like is sessionManagement enabled in the application.cfm/cfc.

IIRC, there used to be an issue with setting session variables and using cflocation on the same page. Don't know if it still applies though.

Hi arrgh, thanks for the help. I have an application.cfm that sets the session management to yes.

<!--- Code gets executed with every page request!! --->
<cfapplication name="login" sessionmanagement="Yes">
<cfparam name="SESSION.login" default="No" type="any">

Well I think I figured out after the posts you, arrgh, and Shalinko posted. I didnt have a <cfset SESSION.login = "No"> on my adminLogin.cfm template. Not sure yet if its working correctly though, as now I have a new error saying the admin table doesnt exist...and I'm looking at it right now! lol


Ok well it DOESNT exist. I created the new rlbAdmin table in Navicat and it shows up fine, but when I look at my databases in DW its not there. Im still confused. I thought when I added things to mysql databases with navicat, it would, when refreshed, show up locally in DW.

ok NOW it is there...showing in DW as well as Navicat. Still getting an ero that says that database table doesnt exists! Strange....lol

Thats when trying to login in remotely...using the URL.
When i try to login locally it gives the element Login is undefined in SESSION error. Obviously I have a couple issues going on. Any advice? TIA

Well I think I figured out after the posts you, arrgh, and Shalinko posted. I didnt have a <cfset SESSION.login = "No"> on my adminLogin.cfm template

But you shouldn't have to! That's the whole point of using CFPARAM. It sets a default for a variable only if that variable doesn't exist ;-) As long as your other page is in covered by your Application.cfm, it should work without having to set the variable manually.

Sorry. I don't use DW.

lol arrgh I agree. everything works locally now! but remotely I still get an error that says the table doesn't exist! As you know I am using Navicat and I created this new table there. The new table shows in Navicat and I even created a quick page with a query to display the records of the new table and it works. This new query page doesnt work remotely, as I get the same error that the table doesn't exist. Maybe I'm really confused and missing out on the concept of MySQL and Navicat! lol Again, I assumed that if I create a table, add records, delete records, whatever, within navicat, because it has a connection to my remote DB server, then everything should be correct on the remote DB server. Am I just totally not grasping something??

Well you're talking about a totally different error now. It sounds like a db error. I can't see the query code from here ;) But with datasources it could be anything from missing permissions, wrong user account used to connect, to a datasource pointing to the wrong db.

Oh my Lord! lol just off from chatting with hosting tech support. The other week I was having a similar issue, so I remember them saying they would move my database, to another server. I am using some hosting space from a friend's site. Anyway, in Navicat, I never changed the server hostname...which they didnt tell me to nor what the new host name was. Well I just changed it and added the new table in question and it works!..sheesh Thanks again! I hate when I post a question and something like this is the real issue...makes it seem like I posted it for nothing. Thanks arrgh!

If nothing else it makes me feel better about times when I've done that myself ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.