Skip to main content
October 19, 2006
Question

Element Undefined in Session

  • October 19, 2006
  • 1 reply
  • 421 views
This code has been working perfectly fine for weeks now and I have not changed a thing and all of the sudden I am getting an "Element Username is undefined in SESSION"

The code is attached, any ideas?
    This topic has been closed for replies.

    1 reply

    Inspiring
    October 19, 2006
    <cfset lgUsername = #Session.Username#>

    That is outside your <cfif> and it is not set yet.

    --
    Ken Ford
    Adobe Community Expert
    Fordwebs, LLC
    http://www.fordwebs.com


    "mikeap" <mikeapeters@gmail.com> wrote in message
    news:eh6pbm$fo1$1@forums.macromedia.com...
    > This code has been working perfectly fine for weeks now and I have not
    > changed
    > a thing and all of the sudden I am getting an "Element Username is
    > undefined in
    > SESSION"
    >
    > The code is attached, any ideas?
    >
    > <cfif IsDefined("FORM.btn_login")>
    > <cfset redirectLoginSuccess="/extranet/home.cfm">
    > <cfset redirectLoginFailed="/extranet/index.cfm?lf=y">
    > <cfquery name="rsUser" datasource="xxx">
    > SELECT Username,Password,Application_ID,App_Access_Level FROM [WEB SMS
    > USER TO
    > APP ROLE] WHERE Username=
    > <cfqueryparam value="#FORM.Username#" cfsqltype="cf_sql_clob"
    > maxlength="50">
    > AND Password=
    > <cfqueryparam value="#FORM.Password#" cfsqltype="cf_sql_clob"
    > maxlength="25">
    > </cfquery>
    > <cfif rsUser.RecordCount NEQ 0>
    > <cfset Session.Username=FORM.Username>
    > <cfset Session.Application_ID=rsUser.Application_ID[1]>
    > <cfset Session.UserAuthorization=rsUser.App_Access_Level[1]>
    > <cflocation url="#redirectLoginSuccess#" addtoken="no">
    > <cfelse>
    > <cflocation url="#redirectLoginFailed#" addtoken="no">
    > </cfif>
    > </cfif>
    >
    > <cfset lgUsername = #Session.Username#>
    >


    October 19, 2006
    The lgUsername is on the successfull page. So once the user logs in successfully, that session variable is created.

    So the fact that I'm able to successfully login means the code is working and it's finding the user in the db and creating the session variable = to the form value. So why isn't the local variable on the login success page not working?

    See what I mean?