Web Hosting Vodahost    

Home Take The Royal Tour! Order Now Features Prices
Go Back   Web Hosting > VodaHost Web Hosting Support > mySQL & PHP

Notices

mySQL & PHP Discussions, information and help with mySQL and PHP.

Reply
 
LinkBack Thread Tools
  #1  
Old 11-26-2007, 11:01 AM
pipesportugal's Avatar
Sergeant Major
 
Join Date: Jul 2007
Location: Oporto - Portugal
Posts: 99
Default To find out who is logged in ?

Hello dear colleagues,

Is there a way using a PHP expression to find out who is logged into my website reserved area ?

I have a field on the database that is set to 0 or 1 depending if the user is looged in or not, but after a while he gets logged out, because of inactive time reason and this field is not geting updated.

Also if he closes the browser without hiting the logout button, I also get the info that they are logged in when on reality they're not.

Is there a way to fix my problem ?

Thanks in advance for all the suggestions,
pipesportugal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old 11-26-2007, 11:19 AM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 8,999
Default Re: To find out who is logged in ?

You should also have a "time" field for each user that needs to be automatically updated with each "hit" (page opening) the user performs. After the set time period (usually 15 minutes) from the last "hit" the script cosiders the user logged off and updates the "logged in" flag field.
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old 11-27-2007, 12:47 AM
pipesportugal's Avatar
Sergeant Major
 
Join Date: Jul 2007
Location: Oporto - Portugal
Posts: 99
Default Re: To find out who is logged in ?

Hi,

What about with the "sessions", "cookies", "setcookies" and globals and all that "strange" php stuff ? no way ?

pipesportugal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old 11-27-2007, 06:33 AM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 8,999
Default Re: To find out who is logged in ?

It DOES use sessions. You see, when a user visits the site, a authorisation session is installed (usually session[username] and session[password]. Or anything similar. With each "hit" (page opening) the autorisation code checks to see if the user is autorised. If the session is valid, it allows the user to view the page. At this point, as happens with this forum where you can see who is logged in, the script updates the users profile record in the database with (usually) the time and the URL he is viewing. Also, usually, there is a Last visit field in the database, that allows the script to keep track of that too.

From this point on, a simple query to the database, can, at any moment, show you who is logged in, by looking into the database to see for the last hit time field having a value that is greater than the (current time - session duration). The query will return the details of all users that have performed a hit in the last 10 - 15 minutes (depending, as i said, on the session duration set by the administrator of the script)
The only actual limitation is that no one will actually log out when leaving the site, so, for those 10 or 15 minutes that the session remains open, the script will still consider the user logged in.
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old 11-27-2007, 04:44 PM
Watdaflip's Avatar
Brigadier General
 
Join Date: Sep 2005
Location: Cincinnati, Ohio
Posts: 1,643
Default Re: To find out who is logged in ?

You would need to implement a time field as naval has suggested, but you can just have a cron job check every so often and if the current time + how long the user can be logged in for is greater then the last recorded activity for that user to log them out.
__________________

Register/Login Script
Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old 11-27-2007, 10:16 PM
pipesportugal's Avatar
Sergeant Major
 
Join Date: Jul 2007
Location: Oporto - Portugal
Posts: 99
Default Re: To find out who is logged in ?

Cool my friends !
Those suggestions were great !

I guess You guys must be already tired of "listening" to this same stuff all the time, but I'll say it anyway:
- You people are the best !!!!

pipesportugal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


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

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 01:54 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC7
2007 VodaHost.com - All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54