Solved

Session Variable Understanding

Posted on 2000-03-15
3
144 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 50 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
RewriteRule to Include HTML, but Not Affect Images 4 71
how to setup ssl access to internal local machine 4 109
wordpress email form 23 72
setup wamp server for first time 2 45
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

896 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now