#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    67
    Rep Power
    11

    Question 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?

    Nathan
    SYM EDGE Creative
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,273
    Rep Power
    968
    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:

    http://www.bpurcell.org/blog/index.c...try&ENTRY=1008
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    67
    Rep Power
    11

    Cool 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.

    Nathan
    SYM EDGE Creative
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,273
    Rep Power
    968
    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.

IMN logo majestic logo threadwatch logo seochat tools logo