LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-05-2006, 03:47 AM   #1
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Rep: Reputation: 30
destroying a session variable after some time in php


In order to show which users are currently viewing my application I used the following method. First I created a table in my databaser with a column called "username". Then whenever a user logs in to the application his username gets added to the table. To show users who are working currently in my application I just query this table. when user logs out his username automatically gets deleted from my table which is fine. But when a user leavs my application without loggin out he is still in my table despite he has closed the application. For example Yahoo also has such problem in its messenger. When a user gets disconnected from the internet he or she is looks on line but only after some time the user becomes offline.
What is the best method to eliminate such problem?
 
Old 02-05-2006, 08:12 AM   #2
Spudley
Member
 
Registered: Mar 2003
Location: Berkshire, England.
Distribution: SuSE 10.0
Posts: 299

Rep: Reputation: 32
Each time they access the page, update a field which tracks the time they last visited; then in your list of users, you can query only those where that time field is less than five minutes ago. (or whatever duration you think is best)

The data will still be in your table, but will be filtered out by the query. If you don't want all that old data clogging up your table, you may want to trigger a regular program to clear out the old records. Otherwise, you could just leave it there, and overwrite it when the same user does eventually come back.

Hope that helps
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Are PHP session variables held in memory when you leave a PHP site? Locura Programming 11 11-16-2008 08:37 PM
PHP: object to variable carlosruiz Programming 2 07-01-2005 11:09 AM
PHP Variable = function? wh33t Programming 2 01-22-2005 06:28 AM
# URL variable in PHP fatman Programming 1 06-04-2004 10:42 PM
time as the value of a variable in C wincrk Programming 5 04-10-2003 02:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration