Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Session Variable Understanding

Posted on 2000-03-15
3
Medium Priority
?
153 Views
Last Modified: 2013-12-24
I am guessing I just don't understand something about session variables so bear with me.

In an APPLICATION.CFM files I set the <CFAPPLICATION> tag and identify the SESSIONMANAGEMENT as on.

Then, in that same file, I create a few session variables (like session.firstname, session.lastname...you get the idea) and default them all to "" to start off with.

Later, in a login page, I confirm a user name and password against a database, retrieve information from that record and place that data into the session variables.  Which works fine (confirmed with a subsequent page for testing by outputting the session variables).

However, and this is where I think I don't fully understand the session object, when I return to the home page, I have an if clause that checks, for example, session.firstname to see if it is set to "".  If it is, I say "Welcome", if it is not I way "Welcome " #session.firstname#.   But it never seems to work...like there is a scoping issue with the session variable I defined.

Is that enough to get a solution to this misunderstanding?

Thanks in advance.  By the way, I have looked at some of Forta's books and while I find some information about sessions I don't seem to find anything that really talks about how to use them appropriately.
0
Comment
Question by:beregoth
  • 2
3 Comments
 
LVL 19

Expert Comment

by:cheekycj
ID: 2622070
don't check if Session.firstname = "" check if it is defined.

<CFIF IsDefined("session.firstname")>

</CFIF>

Does that help?

CJ
0
 
LVL 19

Accepted Solution

by:
cheekycj earned 150 total points
ID: 2622072
don't check if Session.firstname = "" check if it is defined.

<CFIF IsDefined("session.firstname")>

</CFIF>

that should help.

CJ
0
 
LVL 1

Author Comment

by:beregoth
ID: 2622092
Thanks...that more or less answered my question.  I think I need to better understand how to set and get information to and from the session object itself.  I do, however, thank you for the advice.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

886 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