Link to home
Start Free TrialLog in
Avatar of Errol Farro
Errol FarroFlag for Aruba

asked on

Session variable error

I am doing the following but gets below error

     <cfif err_Login EQ " ">
           <cfset session.Username = #form.txt_UserName#>
          <cflocation url="usersMenuForm.cfm">  
     </cfif>

In usersMenuForm.cfm the following message is displayed when doing <cfoutput>#session.Username#</cfoutput>

Element USERNAME is undefined in SESSION
Avatar of rob_lorentz
rob_lorentz



do you have session management turned on in your application.cfm?

<cfapplication name="yourApp" sessionManagement="yes">
Avatar of Errol Farro

ASKER

Still getting the same message. Here is my code. Must cfapplication be entered in all the forms

<cfapplication name="usersValidateForm" sessionManagement="yes">
...
...
      <cfif err_Login EQ " ">
             <cfset Session.Username = #form.txt_UserName#>
            <cflocation url="usersMenuForm.cfm">  
      </cfif>


In ="usersMenuForm.cfm" I have

<cfoutput> #Session.Username#</cfoutput>  
This is a duplicate of the other question here:

http:Q_21347022.html


As I answered there:

 well, are you sure it is being set?

Really the code should look like this:

<cfif Len(Trim(err_Login)) EQ 0>
       <cflock scope="session" timeout="10" type="exclusive">
           <cfset session.Username = form.txt_UserName>
       </cflock>
        <cflocation url="usersMenuForm.cfm">  
</cfif>

Also if you don't have session management turned on in your application.cfm file or if you have cookies disallowed then this will not work.

If cookies are disallowed you can try

<cflocation url="usersMenuForm.cfm">   --> <cflocation url="usersMenuForm.cfm" addtoken="yes">  
ASKER CERTIFIED SOLUTION
Avatar of Meps
Meps
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial