Solved

Session Variable Understanding

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IIS 8.5 2 52
ColdFusion Rereplace 3 87
Is it true tt IIS7 can't support TLSv1.2 if OS is on Win2008 1 77
Windows Server 2102 R2 - IIS 8.5 redirection assistance ? 7 37
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 …
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

680 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