Solved

Check if users are currently online using PHP,JavaScript or MYSQL.

Posted on 2011-03-06
4
423 Views
Last Modified: 2012-06-27
Hi,
I have a users table that gets updated with a users session id when they login to my website.

I then check the users table to see which users are currently online.

Is there a way to delete the session id from the users table if the users has been inactive after say 20 mins or if they have forgotton to logoff or have simply shut down their browser or PC?

Can this be done with PHP or JavaScript, should I add a timestamp for the last time the user did something and perhaps run a CRON job to delete users that have not done anything in the last 20 mins?

Thanks in advance for your feedback.
0
Comment
Question by:sabecs
4 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 35045220
Are you talking about the 'session_id' in PHP sessions or a variable you're creating?  Like her: http://us3.php.net/manual/en/function.session-id.php ??
0
 

Author Comment

by:sabecs
ID: 35045251
Hi Dave, I am talking about 'session_id' in PHP sessions .
0
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 500 total points
ID: 35045647
0
 
LVL 2

Expert Comment

by:sapparod
ID: 35067916
I think you have to config php.ini. This will remove inactive session from system.

session.gc_maxlifetime = 60
session.gc_probability = 100
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now