Current location: Hot Scripts Forums » Programming Languages » PHP » how many session that are in sesion


how many session that are in sesion

Reply
  #1 (permalink)  
Old 06-11-06, 02:55 PM
mjr mjr is offline
Newbie Coder
 
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Question how many session that are in sesion

you like on the bottom of forums it show who is online and on myspace it show who is on line to well how do you show who is online with sesions
Reply With Quote
  #2 (permalink)  
Old 06-11-06, 03:17 PM
Anastas Anastas is offline
Wannabe Coder
 
Join Date: Mar 2005
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
You could write some code that not only creates a session but also inserts the just created session's data into a MySQL table. Then you could use some javscript that deletes the active session from the MySQL when the browser window is closed. After that, it's just a simple matter of counting the number of rows in the MySQL table.
Reply With Quote
  #3 (permalink)  
Old 06-11-06, 03:26 PM
mjr mjr is offline
Newbie Coder
 
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
is there another sugestgion i am not good with javascript

nor mostly understand it
Reply With Quote
  #4 (permalink)  
Old 06-11-06, 03:27 PM
mjr mjr is offline
Newbie Coder
 
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
that is if you know the java script
Reply With Quote
  #5 (permalink)  
Old 06-11-06, 03:38 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
I don't think it's possible with Javascript alone. Maybe AJAX.. But I wouldn't do that.

I would store the user IP plus timestamp in the database and only show the entries that are less than for example 20 minutes old. Do you have a user management system that you want to use, or do you just want to display the IPs?
Reply With Quote
  #6 (permalink)  
Old 06-11-06, 03:40 PM
Anastas Anastas is offline
Wannabe Coder
 
Join Date: Mar 2005
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by nico_swd
I don't think it's possible with Javascript alone. Maybe AJAX.. But I wouldn't do that.

I would store the user IP plus timestamp in the database and only show the entries that are less than for example 20 minutes old. Do you have a user management system that you want to use, or do you just want to display the IPs?
Why not use AJAX? Seems like it would be much more accurate, whcih would be significant on high-traffic sites.
Reply With Quote
  #7 (permalink)  
Old 06-11-06, 03:50 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
I'm not even too sure if that's possible. When you hit the close button the window closes immediatley. I don't think you can prevent the user to close the window when he wants to. AJAX would have to communicate with the server first, which takes some time. Plus this won't work if the user has javascript disabled.
Reply With Quote
  #8 (permalink)  
Old 06-11-06, 03:52 PM
Anastas Anastas is offline
Wannabe Coder
 
Join Date: Mar 2005
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
Very few people have javascript disabled. You can check if the user has javascript disabled - if it's disabled, then add a timestamp, if not, the the onUnload event can delete the session from the database. Seems perfectly viable to me.
Reply With Quote
  #9 (permalink)  
Old 06-11-06, 04:18 PM
mjr mjr is offline
Newbie Coder
 
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
ya agree no ajax i am not good with java and xml only thing with xml and php is rss feed those are the best with php
Reply With Quote
  #10 (permalink)  
Old 06-11-06, 04:21 PM
mjr mjr is offline
Newbie Coder
 
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Talking

ill go with the timestamps that is clever
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I'm desperate for work, I'll do any work for cheap [PHP/MySQL] Anastas Job Offers & Assistance 17 02-12-06 11:18 AM
arrays passed via session rjwebgraphix PHP 1 01-22-06 08:00 PM
urgent: session timeout occurs unexpectedly in ASP.net seemagaur ASP.NET 3 10-11-05 11:10 PM
Session validation sharad JavaScript 1 08-15-05 05:47 PM
how do I manage session cookies? Jansen Windows .NET Programming 1 05-04-05 03:32 PM


All times are GMT -5. The time now is 07:17 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.