?
Solved

Session variable error

Posted on 2005-03-14
4
Medium Priority
?
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month10 days, 2 hours left to enroll

762 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