Thursday 15 March 2012

coldfusion - Session Variables, welcome messages -


Why does not this work? My welcome message, it just does not appear:

  & lt; P & gt; Welcome & lt; Cfoutput & gt; # Recordset1.UserID # & lt; / Cfoutput & gt; & Lt; / P & gt;  

Session variables on the login page I created:

  & lt; Cflock timeout = 999 scope = "session" type = "special" & gt; & Lt; Cfset session .IDUsers = '' & gt; & Lt; / Cflock & gt;  

Is this wrong? On the index page, where I am trying to display my welcome message, I have:

  & lt; Cfquery name = "Recordset1" data source = "cafegosip" & gt; Select from users * where the user IDUsers = & lt; Cfqueryparam value = "# session. Idzer #" & gt; & Lt; / Cfquery & gt;  

I'm not sure whether it works, or is it necessary?

If you set the userid stored in the session to be an empty string, when you query it on it , You will only receive users for whom ID is an empty string, none of them should be. Therefore, the query is returning the blank set, and your page is not displaying the (right) User ID.

How are you starting to identify the user? Do they ask during a database when they log in? Are you collecting cookies? Reading tarot cards? To work for it, at some point, you have to store the correct user id, maybe in session. To do this, you must first know who the user is.

In addition, if you are using CF6 +, you probably do not need cflock. It is now used to prevent running conditions, as CF is now thread-protected.


No comments:

Post a Comment