Solved

Session Variable Understanding

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

24 Experts available now in Live!

Get 1:1 Help Now