Creating A ‘who Is Online Now’ Script
Page 1 of 114 Replies - 9064 Views - Last Post: 10 February 2005 - 09:46 AM
#1
Creating A ‘who Is Online Now’ Script
Posted 20 January 2005 - 09:00 AM
I can track users logging in by inserting the date into a table, but I have no way of knowing when they log out – although there is a Log Out button, obviously I cannot force users to click it instead of going elsewhere or closing the window.
We are not using any web stats program, but I’m convinced it can be done with a ColdFusion Function, Tokens, Sessions, or Cookies, etc.
Any ideas or advice?
Replies To: Creating A ‘who Is Online Now’ Script
#2
Re: Creating A ‘who Is Online Now’ Script
Posted 20 January 2005 - 09:04 AM
Pull all users with a timestamp in the past 60 minutes...
Then put code in the same page that records the last_activity to also check for sessions that are older than say... 24 hours and delete those sessions from the database.
That's how our system works... or there about.
#3
Re: Creating A ‘who Is Online Now’ Script
Posted 20 January 2005 - 09:17 AM
skyhawk133, on Jan 20 2005, 09:04 AM, said:
Pull all users with a timestamp in the past 60 minutes...
Then put code in the same page that records the last_activity to also check for sessions that are older than say... 24 hours and delete those sessions from the database.
That's how our system works... or there about.
Bingo! Cheers for the help.
I guess deep down, I'm just after something absolutely accurate.
#4
Re: Creating A ‘who Is Online Now’ Script
Posted 20 January 2005 - 09:28 AM
#5
Re: Creating A ‘who Is Online Now’ Script
Posted 20 January 2005 - 09:35 AM
skyhawk133, on Jan 20 2005, 09:28 AM, said:
Quite right - thanks again.
#6
Re: Creating A ‘who Is Online Now’ Script
Posted 07 February 2005 - 02:46 AM
- The main page index.cfm shows the same content even if the user is authenticated or not (some contents from databases into tables -not important by now-).
- There is a login section also in the index page, so if users want to perform some activities exclusive for registered users they can authenticate through it.
- If authentication fails, the index.cfm page is displayed again with the only difference of having a "invalid username/password try again" in the login section.
- If the authentication succeed the index.cfm would show again and say in the login section "welcome username!" and a buttom which says "logout".
- the index page is showing all the content, so it reloads and reloads itself showing different content from database according to the parameters passed through URL.
The problems/questions I have are:
-can I store some user defined values in the session object like "session username and session user id"? n this case how can I retrieve them if I reload the same page over and over again? should I change my system schema?
-While authenticating I don't know how to keep the session variables since if I ask in the begining of the document: "if is defined session username then do this" it presents me "session object is not defined" of course, because Is defined below if user authentication succeed. Seems like the session variables are lost and I can not make them stay in server instead of get lost with application reload.
- I need to retrieve all the usersname stored in the session object for all the users online, for example, if there is 3 users= john, lucas, manuel I can write in the page = "registered users online 3: john, lucas, manuel - not registered: 120"
I'd appreciate any help, and thanks in advance.
M.-
#7
Re: Creating A ‘who Is Online Now’ Script
Posted 08 February 2005 - 03:06 AM
1)Created an application.cfm that
- declares an application with session management, client management, cookies and declare expiration dates.
- creates a parameter for this application which is "session.LoggedIn" with "false" as default value.
- redirects everybody whose tries to perform an action without been logged in to the index.cfm with the login
option.
- If there is a "logout" request, then executes: StructClear(Session)
- enable cookies and insert id and token values (I haven't use this values yet)
2) in the index.cfm the structure is like follows:
if cgi method is post
| if user has not initiated session and login request is defined {
| | execute login query
| | if recordcount is 0{ redirect to index with fail login message}
| | else {create session, assign some values to session, write cookies, and redirect to logged in page}
| | end if
| else (user already initiated session) {open index.cfm with logged in active}
| end if
| if request is logout {clear session, redirect to index with login page active }
else {open index with login page active}
end if
Ok this works, but still not optimum. I'll follow the idea of declare a structure which stores every user name and
then show in the login page (by now I'm solving this by using a "insert into track table username, userid and time
of transaction". then verify time of last transaction of users and if time is more than 30 min or they request to
logout then delete them from table- of course it requires that for every refresh of page, every request I need to
update time of user with now() value).
So, my new questions/problems I have are:
- should I use the cookies values (id and token, also username a and userid are defined there) to check in case some
user closes his browser and open new one of the site with his session time still active to keep him connected as if
he never has closed the browser?, in this case how can I do?
- in case of replace the database for structures in server memory, how is the best way to get around it?
- In case a user closes his browser window, can I end his session?
- please I receive with joy any comments of advices or links or code about users authentication and security.
Thanks in advance, hope to hear about you soon.
M.-
#8
Re: Creating A ‘who Is Online Now’ Script
Posted 08 February 2005 - 01:02 PM
thanks again.
M.-
#9
Re: Creating A ‘who Is Online Now’ Script
Posted 08 February 2005 - 06:39 PM
#10
Re: Creating A ‘who Is Online Now’ Script
Posted 08 February 2005 - 07:03 PM
#11
Re: Creating A ‘who Is Online Now’ Script
Posted 09 February 2005 - 02:26 AM
Thanks anyway for your time. If still somebody knows security related issues in coldfusion it would be great.
M.-
#12
Re: Creating A ‘who Is Online Now’ Script
Posted 09 February 2005 - 09:01 AM
#13
Re: Creating A ‘who Is Online Now’ Script
Posted 09 February 2005 - 03:34 PM
Can you explain exactly what problem you're having and we'll go from there.
#14
Re: Creating A ‘who Is Online Now’ Script
Posted 10 February 2005 - 03:13 AM
Well starting from this point of showing current active users without store them in data base could be a great plan.
I'm wondering if is possible to declare a structure that holds the session.usernames everytime somebody login. This should be a thread process on server I think.
In case there is no way of store sessions in a structure, but working with a database I have some questions:
- how can I log them off when they close the window?. Like -script: on windows close [ cfcode execute query of del user from table ]-
-If want to log them off automaticaly every 20 min of inactivity for example, user x with id 3 performs an action on time 00:04 and then he reloads on 00:06 (counter was 2min, but user reloaded and the counter is reset on this time) but on 00:26 the counter is finished-20 min- then I delete this user from active users.
- Updating the time stamp on database everytime users perform an action is efficient?, if I want to do something like update the time stamp on a cookie ?, I need some orientation here...
Thanks in advance for your help.
M.-
#15
Re: Creating A ‘who Is Online Now’ Script
Posted 10 February 2005 - 09:46 AM
Hope that helps... you can still keep the user session active using the session scope, but the application scope should help you achieve your desired result.
|
|

New Topic/Question
Reply



MultiQuote




|