ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 17th, 2005, 08:26 AM
charmed0rz charmed0rz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 142 charmed0rz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 49 m 31 sec
Reputation Power: 5
Show logged in user_name

I have a table with user_ID and user_name.. their session is determined on their user_id so i was wondering how i could show the user_name of those logged in...

here is my login_process page:

<!--- Get all records from the database that match this users credentials --->
<cfquery name="qVerify" datasource="userLogin">
SELECT user_id, user_name, user_pass
FROM registration_info
WHERE email = '#email#'
AND user_pass = '#user_pass#'
</cfquery>


<cfif qVerify.RecordCount>
<!--- This user has logged in correctly, change the value of the session.allowin value --->
<cfset session.allowin = "True">
<cfset session.user_id = qVerify.user_id>
<!--- Now welcome user and redirect to "members_only.cfm" --->
<script>
alert("You have been successfully logged in! ");
self.location="/members_only.cfm";
</script>
< cfelse>
<!--- this user did not log in correctly, alert and redirect to the login page --->
<script>
alert("Incorrect email address or password, please try again.");
self.location="javascript:history.go(-1)";
</script>
</cfif>


and what would i need to put for it to show their user_name

Reply With Quote
  #2  
Old January 17th, 2005, 08:34 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,692 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 43 m 41 sec
Reputation Power: 53
Could you not just set a session variable for the user name? Then you could show it anywhere you want to.

By the way, using Javascript like that to enforce security is a bad idea because Javascript can be easily disabled. I'd use a <cflocation> instead unless you really aren't worried about it.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old January 17th, 2005, 09:25 AM
charmed0rz charmed0rz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 142 charmed0rz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 49 m 31 sec
Reputation Power: 5
I am new to coldfusion so i dont know all the tags.. ill look into it right now though, thanks!

About the post though..

Would I just add: <cfset session.user_name = qVerify.user_name>
under the user_ID one? How can i make it so it logs them out after a certain period of time if they dont actually log out? AND what exactly do i put to actually output the user_id or user_name? Thanks for all the help


Quote:
Originally Posted by kiteless
Could you not just set a session variable for the user name? Then you could show it anywhere you want to.

By the way, using Javascript like that to enforce security is a bad idea because Javascript can be easily disabled. I'd use a <cflocation> instead unless you really aren't worried about it.

Reply With Quote
  #4  
Old January 17th, 2005, 04:40 PM
charmed0rz charmed0rz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 142 charmed0rz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 49 m 31 sec
Reputation Power: 5
thats weird, theres 2 replies but it only says 1. *edited well now 2 when theres 3* :P

Quote:
Originally Posted by charmed0rz
I am new to coldfusion so i dont know all the tags.. ill look into it right now though, thanks!

About the post though..

Would I just add: <cfset session.user_name = qVerify.user_name>
under the user_ID one? How can i make it so it logs them out after a certain period of time if they dont actually log out? AND what exactly do i put to actually output the user_id or user_name? Thanks for all the help

Reply With Quote
  #5  
Old January 17th, 2005, 06:13 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,692 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 43 m 41 sec
Reputation Power: 53
Yes you could put:

<cfset session.user_id = qVerify.user_id>
<cfset session.user_name = qVerify.user_name>

Session variables automatically time out after a certain period of inactivity. This time span is set in the ColdFusion administrator or in the <cfapplication> tag for the application. The value set in the CF admin is the maximum value allowed.

You'd output it like this:

<cfoutput>#session.user_name#</cfoutput>

If you're not up to date on these kinds of things, I'd recommend Ben Forta's CF book. And keep in mind that when dealing with variables in shared scopes (session, application, and server scopes) you must start to consider threading and race conditions. Normally it's not a huge concern, in professional development it is something that must be addressed.

Reply With Quote
  #6  
Old January 17th, 2005, 07:32 PM
charmed0rz charmed0rz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 142 charmed0rz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 49 m 31 sec
Reputation Power: 5
If i was logged in, and that was on the page it would output my user_name, yes.. but what if i am wanting to see the others who are logged in? like showing the user_name of all online users.. or maybe im missing something


Quote:
Originally Posted by kiteless
Yes you could put:

<cfset session.user_id = qVerify.user_id>
<cfset session.user_name = qVerify.user_name>

Session variables automatically time out after a certain period of inactivity. This time span is set in the ColdFusion administrator or in the <cfapplication> tag for the application. The value set in the CF admin is the maximum value allowed.

You'd output it like this:

<cfoutput>#session.user_name#</cfoutput>

If you're not up to date on these kinds of things, I'd recommend Ben Forta's CF book. And keep in mind that when dealing with variables in shared scopes (session, application, and server scopes) you must start to consider threading and race conditions. Normally it's not a huge concern, in professional development it is something that must be addressed.

Reply With Quote
  #7  
Old January 17th, 2005, 09:14 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,692 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 43 m 41 sec
Reputation Power: 53
Sessions are unique to each user. Getting information about all active sessions is much more complicated. I believe there is an unsupported call that could be made to the underlying Java classes that deal with sessions. But this could (and probably will) break in CFMX 7 due out shortly.

You could also keep track of the sessions yourself, maybe setting an application variable in addition to the session data when the user logs in. Application-scoped variables are available across all user sessions. But consideration of threading issues is even more important when dealing with application variables.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Show logged in user_name


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT