Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Session variable error

Posted on 2005-03-14
4
Medium Priority
?
196 Views
Last Modified: 2013-12-24
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
0
Comment
Question by:Errol Farro
4 Comments
 
LVL 10

Expert Comment

by:rob_lorentz
ID: 13535993


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

<cfapplication name="yourApp" sessionManagement="yes">
0
 

Author Comment

by:Errol Farro
ID: 13536324
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>  
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 13536641
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">  
0
 
LVL 3

Accepted Solution

by:
Meps earned 375 total points
ID: 13539368
Try this,
<cfdump var="#session#">

Just type that in at the bottom of a page to see all of your session variables.

Also to keep yourself from going nuts, try to put a else statement when trouble shooting.  There might be a problem with the IF statement that is not setting your user name.  So else <cfset session.Username = junglebook>  If you see your else statement then you know it is something wrong with your if statement not the application, or it's sessions.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses
Course of the Month15 days, 23 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question