Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session Variable Problem

Status
Not open for further replies.

NateUNI

MIS
Jan 3, 2002
132
US
After i login to my site, i want to display the username of the person that just logged in. In my login.cfm i have <cfset Session.UserName=&quot;#Login.UserName#&quot;> which set the variable, then in my next page (NewPO.cfm) i have <cfoutput>#Session.UserName#</cfoutput>, which upon execution of the code gives the following error:

Element USERNAME is undefined in SESSION.


The Error Occurred in C:\Inetpub\ line 68

66 :
67 : <body>
68 : <cfoutput>#Session.UserName#</cfoutput>
69 : <cfform name=&quot;form1&quot; method=&quot;post&quot; action=&quot;POInput.cfm&quot;>
70 : <table>

Any ideas on what is causing this problem?? Thanks!
 
Is the session variable defined in applcation.cfm? DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
no its not, just a cfset in login.cfm, do all session var. need to be first defined within application.cfm?
 
Do you have a <cfapplication> tag to enable session management?

Wes
 
yes i do, and have sessionmanagement to yes. I did however seem to get it to work when i included CFID=#Session.CFID#&CFTOKEN=#Session.CFTOKEN#
to all my links. Is this required to use session variables?? Thanks!
 
Try adding this code to your application.cfm

<!--- preserve client/session variables until browser closes --->
<cfset Cookie.CFID = session.CFID>
<cfset Cookie.CFTOKEN = session.CFTOKEN>

This should keep your session variables defined until the browser closes.

By adding this code your original code should work just fine.

Chris

 
I had trouble once with session variables when I would link to different folders. The problem was the name in the cfapplication has to be the same if you have multiple tags or you will lose all session variables

Wes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top