Solved

Session Variable Understanding

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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

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 …
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

860 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