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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Session Variables

Status
Not open for further replies.

RonMcNatt

Technical User
May 22, 2002
32
US
I'm trying to use a session variable to capture the userid from my Login page.

I've enabled sessionmanagement on the application.cfm page and created a varaible called <CfSet Session.userloginname = &quot;Default&quot;>

On the login page I have:
<cfif IsDefined(&quot;Form.userlogin&quot;)>
<cfset Session.UserLoginName = #userlogin#>
</cfif>


After the user is autheniticated, I have a page where I list an output statement:
<cfoutput>#Session.Login.UserLoginName#</cfoutput>

My problem is that &quot;Default&quot; is the only value that ever shows on a cfoutput. I have manually changed <cfset session.userloginname = &quot;cherries&quot;> and the
output statement will show &quot;cherries&quot; for that page, but the value of &quot;default&quot; returns on the following page.

Any help would be greatly appreciated.

Ron McNatt
 
Maybe you've already tried these, but some thoughts...

Are you sure that FORM.userlogin really does exist, and the spelling is correct? Check what form variables are coming in by turning on debugging output:
<cfsetting showdebugoutput=&quot;yes&quot;>

Are you really making it into the <cfif> loop? Check by modifying your code:
<cfif IsDefined(&quot;Form.userlogin&quot;)>
<p>Made it!</p>
<cfset Session.UserLoginName = #userlogin#>
<cfelse>
<p>Failed!</p>
</cfif>

This shouldn't matter, but the proper way to assign the value is either
<cfset Session.UserLoginName = &quot;#userlogin#&quot;>
Or
<cfset Session.UserLoginName = userlogin>
Note the use (or not) of pound signs.

Good luck!

 
Hi,
The application.cfm gets called by every page so you are reseting to the default everytime. Move the default seting off the application.cfm and you sould be better.
John
 
Thank you VERY MUCH. It's always the little things!! I read several tutorial trying to set it up correctly.

Thanks again,

Ron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top