|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Logging out first user
If a user has two accounts, they are on one, then get on the other, and do something that updates the database, sometimes it uses the first users info/details.. how can i change it so it logs out the first person if someone logs in after them on the same comp/different comp?
|
|
#2
|
|||
|
|||
|
Set some sort of cookie to identify each user who logs in. Then track this as a session variable as well. Then when the user tries to do something you can compare the session variable to the cookie variable, and if they are different, you know that you're dealing with a different user.
__________________
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 |
|
#3
|
|||
|
|||
|
Along with this, I was wondering how to log out a user if you use cookies and sessions to track a user without the need to close the browser. If I need to start a new post on this, I will, but I thought it went along with the previous question.
I know you can use the following when the browser closes, because the cookie is gone, and closing the browser closes out the session, but what about when you just want to switch to a different user without closing the browser first: <cfcookie expires="NOW" name="UserID" value="#cookie.UserID#"> |
|
#4
|
|||
|
|||
|
In that case they would have to click a "logout now" link, similiar to how most web sites like yahoo or gmail do it.
|
|
#5
|
|||
|
|||
|
Just in case anyone wanted to know what I did to solve the problem of logging out a user through both cookies and sessions.
<cfif isDefined('form.logout')><cfcookie expires="NOW" name="UserID" value="#cookie.UserID#"><cfloop collection=#session# item="i"> <cfset StructDelete(session,i)> </cfloop> <cflocation url = "somepage.cfm" addtoken="no"> </cfif> This deletes all sessions, which you sometimes might not want. I image you could set <cflock timeout=20 scope="Session" type="Exclusive"> <cfset StructDelete(Session, "Items")> </cflock> to delete a certain session variable, although I have not tested this. Can anyone confirm that you can choose which sessions to delete using this method, or are u stuck deleting all sessions? |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Logging out first user |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|