April 2nd, 2004, 05:34 AM
GetAuthUser() is not persistent?
***Coldfusion MX 6.1 Question***
Anyone have an idea why my GetAuthUser() will have a value on one page but be empty on another page?
My login form does double duty by displaying the form THEN running a query once the form is submitted. After the query completes I use CFLOGIN to populate the GetAuthUser() function.
When I test for GetAuthUser() on the login form it works fine BUT when I see if the value was passed to a secondary page, it's empty. I thought GetAuthUser() was persistent during a single browser session?
SYM EDGE Creative
April 2nd, 2004, 01:53 PM
I've been using CF for over 6 years and CFMX since it was in beta. And I have never gotten the whole CFLOGIN thing to work for me. Though I have not tried it in a while. I'd recommend looking at some examples and comparing to what you have to see if you're missing something. Take a look at:
April 2nd, 2004, 05:58 PM
A real ANSWER to this question...
If your searching for an answer to my question...I've got it.
The CFLOGIN structure only works if all the login code is INSIDE THE APPLICATION.CFM template. Check this out, Application variables always persist whereas unless you pass variables using one of the three internal 'state' scopes (SESSION, APPLICATION, and CLIENT) each page of the site remains 'stateless'.
This was the root of the problem I was having. I had the CFLOGIN code OUTSIDE the Application template so the value of GetAuthUser() was disappearing between the two pages but was available to the SAME PAGE THAT FILLED IN THE variable.
So, i created an INCLUDE file that was called by the Application.cfm template. It then ran the CFIF blocks that checked FORM variables and ran the query. Once that completed, the LOGINUSER tag was used to populate the GetAuthUser() function WHILE IT WAS INCLUDED IN THE APPLICATION template. Grrrr...this kind of stuff should be well know...
I hope this helped someone out and thanks for the replies.
SYM EDGE Creative
April 5th, 2004, 09:54 AM
Actually, I think it is not so much that CFLOGIN must be in the application.cfm file, but that CFLOGIN must be encountered SOMEWHERE prior to you calling any functions like getAuthUser(). It's just very easy to do this by putting CFLOGIN in the application.cfm file. I think if you wanted to you could avoid using application.cfm and instead have a framework like Fusebox or Mach-II which has preprocess plugin phases that behave much like application.cfm. I'm not 100% sure but I am pretty sure that this is the case, just to clarify. Glad you figured out the issue anyway.